[CONF] Apache Tapestry > Link Components FAQ

2010-10-23 Thread confluence







Link Components FAQ
Page edited by Howard M. Lewis Ship


 Changes (6)
 



...
These components do not have parameters to allow you to specify query parameters for the link; they both allow you to specify a _context_ (one or more values to encode into the request path).  
However, you can accomplish the same thing with a little code and markup.  For example, to create a link to another page and pass a query parameter, you can replace your PageLink component with a standard {{}} tag: 
a standard {{}} tag: 
 {code:controls=true|linenumbers=true} 
...
Link link = linkSource.createPageRenderLinkWithContext(DisplayProfile.class, user);  
link.addParameter("detail", "true"); 
link.addParameterValue("detail", true); 
 return link; 
...
{code}  
The @RequestParameter annotation directs Tapestry to extract the query parameter from the request and coerce it to type boolean.  You can use any reasonable type for such a parameter (int, long and Date are common). 
 
A similar technique can be used to add query parmeters to component event URLs (the type generated by the ActionLink or EventLink URLs, components), by injecting the ComponentResources, and invoking method {{createEventLink()}}. 

Full Content

Link Components

How do I add query parameters to a PageLink or ActionLink?

These components do not have parameters to allow you to specify query parameters for the link; they both allow you to specify a context (one or more values to encode into the request path).

However, you can accomplish the same thing with a little code and markup.  For example, to create a link to another page and pass a query parameter, you can replace your PageLink component with a standard  tag:



"${profilePageLink}">Display Profile (w/ full details)



In the matching Java class, you can create the Link programmatically:



  @Inject
  private PageRenderLinkSource linkSource;

  public Link getProfilePageLink()
  {
Link link = linkSource.createPageRenderLinkWithContext(DisplayProfile.class, user);

link.addParameterValue("detail", true);

return link;
  }



... and in the DisplayProfile page:



public class DisplayProfile
{
  void onActivate(@RequestParameter("detail") boolean detail)
  {
. . .
  }
}



The @RequestParameter annotation directs Tapestry to extract the query parameter from the request and coerce it to type boolean.  You can use any reasonable type for such a parameter (int, long and Date are common).

A similar technique can be used to add query parmeters to component event URLs (the type generated by the ActionLink or EventLink components), by injecting the ComponentResources, and invoking method createEventLink().



Change Notification Preferences

View Online
|
View Changes









[CONF] Apache Tapestry > Hibernate Support FAQ

2010-10-23 Thread confluence







Hibernate Support FAQ
Page edited by Howard M. Lewis Ship


 Changes (4)
 



h2. Hibernate Support  
h3. How do I get Hibernate to startup up when the application starts up, rather than lazily with the first request for the application? 
with the first request for the application? 
 
This was a minor problem in 5.0; by 5.1 it was is just a matter of overriding the configuration system {{tapestry.hibernate-early-startup}} to "true". 
{{tapestry.hibernate-early-startup}} to "true". 

Full Content

Hibernate Support

How do I get Hibernate to startup up when the application starts up, rather than lazily with the first request for the application?

This was a minor problem in 5.0; by 5.1 it is just a matter of overriding the configuration system tapestry.hibernate-early-startup to "true".



Change Notification Preferences

View Online
|
View Changes









[CONF] Apache Tapestry > Ajax Components

2010-10-23 Thread confluence







Ajax Components
Page edited by Howard M. Lewis Ship


 Changes (9)
 



...
So, when the search form is submitted, the resulting search hits are collected.  In the same request, the searchResults block is rendered, package, and sent to the client.  The form inside the client-side Zone {{}} is replaced with the list of hits.  
In many cases, you just want to re-render the Zone itself, to display updated content.  In that case, you don't need a seperate {{}}, instead you can use @InjectComponent to inject the Zone object itself, and return the Zone's body: 
 
{code:controls=true|linenumbers=true}   @InjectComponent   private Zone statusZone;Object onActionFromUpdateStatus()   { return statusZone.getBody();   } {code} 
h3. How to I update multiple zones in a single event handler?  
To do this, you must know, on the server, the client ids of each Zone. That's one of the reasons that you will generally set the Zone's 
client id (via the Zone's id parameter), rather than let Tapestry assign a client id for you. 
 
Instead From the event handler method, instead of returning a Block or a Component, return a multi-zone update: 
 {code:controls=true|linenumbers=true} 
...
{code}  
What's happening here is that Tapestry is working to prevent unwanted id clashes as part of the page update.  In an HTML document, each {{id}} is expected to be unique; most _javascript_ is keyed off of the {{id}} field, for instance. 
expected to be unique; most _javascript_ is keyed off of the {{id}} field, for instance. 
 In a full page render, components don't just use their component id ({{t:id}}) as their client id; instead they use the {{_javascript_Support}} environmental to allocate a unique id. When there's no loops or conflicts, the client id matches the component id. 
...
When the component is inside a loop, a suffix is appended:  {{firstName}}, {{firstName_0}}, {{firstName_1}}, etc.  
When the component is rendered as part of an Ajax partial page update, the rules are different. Since Tapestry doesn't know what content has been rendered onto the page previously, it can't use its normal tricks to ensure that ids are unique. 
rendered onto the page previously, it can't use its normal tricks to ensure that ids are unique. 
 Instead, Tapestry creates a random-ish unique id suffix, such as "12a820cc40e" in the example; this suffix is appended to all allocated ids to ensure that they do not conflict with previously rendered ids. 

Full Content

Ajax Components

Do I have to specify both id and t:id for Zone components?

The examples for the Zone component (in the Component Reference) consistently specify both id and t:id and this is probably a good idea.

Generally speaking, if you don't specify the client-side id (the id attribute), it will be the same as the Tapestry component id (t:id).

However, there are any number of exceptions to this rule. The Zone may be rendering inside a Loop (in which case, each rendering will have a unique client side id). The Zone may be rendering as part of a partial page render, in which case, a random unique id is inserted into the id. There are other examples where Tapestry component ids in nested components may also clash.

The point is, to be sure, specify the exact client id.  This will be the value for the zone parameter of the triggering component (such as a Form, PageLink, ActionLink, etc.).

How do update the content of a Zone from an event handler method?

When a client-side link or form triggers an update, the return value from the event handler method is used to construct a partial page response; this partial page response includes markup content that is used to update the Zone's client-side  element.

Where does that content come from?  You inject it into your page.



"search" t:id="searchZone">
  "searchForm" zone="searchZone">
"query" size="20"/>
"submit" value="Search"/>
  


"searchResults">
  
"loop" source="searchHits" value="searchHit">${searchHit}
  






  @Inject
  private Block searchResults;

  Object onSuccessFromSearchForm()
  {
searchHits = searchService.performSearch(query);

return searchResults;
  }



So, when the search form is submitted, the resulting search hits are collected.  In the same request, the searchResults block is rendered, package, and sent to the client.  The form inside the client-side Zone  is replaced with the list of hits.

In many cases, you just want to re-render the Zone itself, to display updated content.  In that case, you don't need a seperate , instead you can use @InjectComponent to inject the

[CONF] Apache Tapestry > Specific Errors

2010-10-23 Thread confluence







Specific Errors
Page edited by Howard M. Lewis Ship


 Changes (1)
 



...
 Only component classes should go in the Tapestry-controlled packages ({{pages}}, {{components}}, {{mixins}} and {{base}} under your application's root package). By convention, simple data objects should go in a {{data}} package, and Hibernate entities should go in an {{entities}} package. 
 h3. I get an error about "Page did not generate any markup when rendered." but I have a template, what happened?  The most common error here is that the case of the page class did not match the case of the template. For example, you might name your class ViewOrders, but name the template vieworders.tml.  The correct name for the template is ViewOrders.tml, matching the case of the Java class name.  Worse, you may find that your application works during development (under Windows, which is case insensitive) but does not work when deployed on a Linux or Unix server, which may be case sensitive.  The other cause of this may be that your template files simply are not being packaged up correctly with the rest of your application. When in doubt, use the Java {{jar}} command to see exactly whats inside your WAR file.  Your page templates should either be in the root folder of the WAR, or package with the corresponding .class file. 

Full Content

Specific Errors

Why do I get the exception "No service implements the interface org.apache.tapestry5.internal.InternalComponentResources" when trying to use the BeanEditForm component?

This can occur when you choose the wrong package for your data object, the object edited by the BeanEditForm component. If you place it in the same package as your pages, Tapestry will treat it like a page, and perform a number of transformation on it, including adding a new constructor.

Only component classes should go in the Tapestry-controlled packages (pages, components, mixins and base under your application's root package). By convention, simple data objects should go in a data package, and Hibernate entities should go in an entities package.

I get an error about "Page did not generate any markup when rendered." but I have a template, what happened?

The most common error here is that the case of the page class did not match the case of the template. For example, you might name your class ViewOrders, but name the template vieworders.tml.  The correct name for the template is ViewOrders.tml, matching the case of the Java class name.

Worse, you may find that your application works during development (under Windows, which is case insensitive) but does not work when deployed on a Linux or Unix server, which may be case sensitive.

The other cause of this may be that your template files simply are not being packaged up correctly with the rest of your application. When in doubt, use the Java jar command to see exactly whats inside your WAR file.  Your page templates should either be in the root folder of the WAR, or package with the corresponding .class file.



Change Notification Preferences

View Online
|
View Changes









[jira] Commented: (TAP5-1324) Quickstart should setup a basic Hibernate application using HSQL

2010-10-23 Thread Mark Shead (JIRA)

[ 
https://issues.apache.org/jira/browse/TAP5-1324?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12924209#action_12924209
 ] 

Mark Shead commented on TAP5-1324:
--

It might be good to have multiple archetypes--each one that adds a bit more 
complexity to the same overall idea. I wouldn't do away with the simple 
archetype because they are ideal for people starting out.  Too much is going to 
make it hard for people to get started.  For example:

1. Basic archetype like we have now, maybe including a sample Selenium test.

2. Archetype that includes hibernate and a basic app--maybe simple user 
management or todo list. The user management would be nice because many apps 
are going to need some form of user management anyway.

3. Archetype that  that includes hibernate, security, user management, file 
uploading etc.  Maybe something along the lines of what you get with Appfuse.


> Quickstart should setup a basic Hibernate application using HSQL
> 
>
> Key: TAP5-1324
> URL: https://issues.apache.org/jira/browse/TAP5-1324
> Project: Tapestry 5
>  Issue Type: Improvement
>  Components: quickstart
>Reporter: Howard M. Lewis Ship
>
> Most people are building an applicaiton using a database, having the 
> Quickstart create a very basic Hibernate-based application (simpler even than 
> the Hotel booking demo), maybe a simple todo list, would be great.
> Perhaps the right thing to do is to scrap the current quickstart, create a 
> quicky project, and experiment with Maven's ability to turna  project into an 
> archetype.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[CONF] Apache Tapestry > General Questions

2010-10-23 Thread confluence







General Questions
Page edited by Howard M. Lewis Ship


 Changes (4)
 



...
h3. How do I get started with Tapestry?  
The easiest way to get started is to use [Apache Maven|http://maven.apache.org] to create your initial project; Maven can use an _archetype_ (a kind of project template) to create a bare-bones Tapestry application for you.  See the [TAPESTRY:Getting Started] page for more details. 
 
One you have Maven installed, execute the command {{mvn archetype:generate \-DarchetypeCatalog=}}{{[http://tapestry.apache.org]}}.  Maven will (after performing a large number of one-time downloads) ask you questions about how to create the new project, including a group id (like a package name) and an artifact id for your new project.   
Even without Maven, Tapestry is quite easy to set up.  You just need to [download|TAPESTRY:Download Tapestry] the binaries and setup your build to place them inside your WAR's WEB-INF/lib folder. The rest is just some one-time [configuration of the web.xml deployment descriptor|TAPESTRY:Configuration]. 
 
{noformat}$ mvn archetype:generate -DarchetypeCatalog=http://tapestry.apache.org [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'archetype'. [INFO]  [INFO] Building Maven Default Project [INFO]task-segment: [archetype:generate] (aggregator-style) [INFO]  [INFO] Preparing archetype:generate [INFO] No goals needed for project - skipping [INFO] [archetype:generate {execution: default-cli}] [INFO] Generating project in Interactive mode [INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0) Choose archetype: 1: http://tapestry.apache.org -> quickstart (Tapestry 5.2.1-SNAPSHOT Quickstart Project) 2: http://tapestry.apache.org -> tapestry-archetype (Tapestry 4.1.6 Archetype) Choose a number: : 1 Choose version:  1: 5.0.19 2: 5.1.0.5 3: 5.2.0 4: 5.2.1-SNAPSHOT Choose a number: : 3 Define value for property 'groupId': : com.example Define value for property 'artifactId': : newapp Define value for property 'version': 1.0-SNAPSHOT: Define value for property 'package': com.example: com.example.newapp Confirm properties configuration: groupId: com.example artifactId: newapp version: 1.0-SNAPSHOT package: com.example.newapp Y:  [INFO]  [INFO] BUILD SUCCESSFUL [INFO]  [INFO] Total time: 25 seconds [INFO] Finished at: Tue Aug 17 14:01:50 PDT 2010 [INFO] Final Memory: 16M/81M [INFO]  /tmp $ tree newapp newapp |-- pom.xml `-- src |-- main |   |-- java |   |   `-- com |   |   `-- example |   |   `-- newapp |   |   |-- components |   |   |   `-- Layout.java |   |   |-- pages |   |   |   |-- About.java |   |   |   |-- Contact.java |   |   |   `-- Index.java |   |   `-- services |   |   `-- AppModule.java |   |-- resources |   |   |-- com |   |   |   `-- example |   |   |   `-- newapp |   |   |   |-- components |   |   |   |   `-- Layout.tml |   |   |   `-- pages |   |   |   `-- Index.properties |   |   `-- log4j.properties |   `-- webapp |   |-- About.tml |   |-- Contact.tml |   |-- Index.tml |   |-- WEB-INF |   |   |-- app.properties |   |   `-- web.xml |   |-- favicon.ico |   `-- layout |   |-- images |   |   |-- img01.jpg |   |   |-- img02.jpg |   |   |-- img03.jpg |   |   |-- img04.jpg |   |   |-- img05.gif |   |   |-- img06.gif |   |   |-- img07.gif |   |   |-- img08.gif |   |   |-- img09.gif |   |   |-- img10.gif |   |   |-- img11.gif |   |   |-- img12.gif |   |   |-- img13.gif |   |   |-- img14.gif |   |   |-- img15.gif |   |   |-- img16.gif |   |   |-- img17.gif |   |   |-- img18.gif |   |   |-- img19.gif |   |   |-- img20.gif |   |   `-- spacer.gif |   |-- layout.css |   `-- license.txt |-- site |   |-- apt |   |   `-- index.apt |   `-- site.xml `-- test |-- conf |   |-- testng.xml |   `-- w

[CONF] Apache Tapestry > Getting Started

2010-10-23 Thread confluence







Getting Started
Page edited by Howard M. Lewis Ship


 Changes (0)
 



...
h2. More  
Learn more about [Tapestry Philosophy|TAPESTRY:Principles] and then checkout our full [Documentation|TAPESTRY:Documentation] page on which you will find a lot of resources written by committers and contributors. 
 h2. Obtain Help 
...

Full Content

See it live !

You can play with Tapestry via our live demonstration applications. To start you can have a look at the Hotel Booking that has been developed by contributors and committers. The whole source code is available at github so you can download and play with it.

Create your first Tapestry project

The easiest way to get started is to use Apache Maven to create your initial project; Maven can use an archetype (a kind of project template) to create a bare-bones Tapestry application for you.

One you have Maven installed, execute the command 


mvn archetype:generate -DarchetypeCatalog=http://tapestry.apache.org



Maven will (after performing a large number of one-time downloads) ask you questions about how to create the new project, including a group id (like a package name) and an artifact id for your new project.


$ mvn archetype:generate -DarchetypeCatalog=http://tapestry.apache.org
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] 
[INFO] Building Maven Default Project
[INFO] task-segment: [archetype:generate] (aggregator-style)
[INFO] 
[INFO] Preparing archetype:generate
[INFO] No goals needed for project - skipping
[INFO] [archetype:generate {execution: default-cli}]
[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
1: http://tapestry.apache.org -> quickstart (Tapestry 5.2.1-SNAPSHOT Quickstart Project)
2: http://tapestry.apache.org -> tapestry-archetype (Tapestry 4.1.6 Archetype)
Choose a number: : 1
Choose version:
1: 5.0.19
2: 5.1.0.5
3: 5.2.0
4: 5.2.1-SNAPSHOT
Choose a number: : 3
Define value for property 'groupId': : com.example
Define value for property 'artifactId': : newapp
Define value for property 'version': 1.0-SNAPSHOT:
Define value for property 'package': com.example: com.example.newapp
Confirm properties configuration:
groupId: com.example
artifactId: newapp
version: 1.0-SNAPSHOT
package: com.example.newapp
Y:
[INFO] 
[INFO] BUILD SUCCESSFUL
[INFO] 
[INFO] Total time: 25 seconds
[INFO] Finished at: Tue Aug 17 14:01:50 PDT 2010
[INFO] Final Memory: 16M/81M
[INFO] 
/tmp
$ tree newapp
newapp
|-- pom.xml
`-- src
|-- main
| |-- java
| | `-- com
| | `-- example
| | `-- newapp
| | |-- components
| | | `-- Layout.java
| | |-- pages
| | | |-- About.java
| | | |-- Contact.java
| | | `-- Index.java
| | `-- services
| | `-- AppModule.java
| |-- resources
| | |-- com
| | | `-- example
| | | `-- newapp
| | | |-- components
| | | | `-- Layout.tml
| | | `-- pages
| | | `-- Index.properties
| | `-- log4j.properties
| `-- webapp
| |-- About.tml
| |-- Contact.tml
| |-- Index.tml
| |-- WEB-INF
| | |-- app.properties
| | `-- web.xml
| |-- favicon.ico
| `-- layout
| |-- images
| | |-- img01.jpg
| | |-- img02.jpg
| | |-- img03.jpg
| | |-- img04.jpg
| | |-- img05.gif
| | |-- img06.gif
| | |-- img07.gif
| | |-- img08.gif
| | |-- img09.gif
| | |-- img10.gif
| | |-- img11.gif
| | |-- img12.gif
| | |-- img13.gif
| | |-- img14.gif
| | |-- img15.gif
| | |-- img16.gif
| | |-- img17.gif
| | |-- img18.gif
| | |-- img19.gif
| | |-- img20.gif
| | `-- spacer.gif
| |-- layout.css
| `-- license.txt
|-- site
| |-- apt
| | `-- index.apt
| `-- site.xml
`-- test
|-- conf
| |-- testng.xml
| `-- webdefault.xml
|-- java
| `-- PLACEHOLDER
`-- resources
`-- PLACEHOLDER

25 directories, 44 files
/tmp
$


The exact content and layout of project generated from the archetype will change across different releases of Tapestry.

Once it is created, you can load it into any IDE and start coding, or use mvn jetty:run




1


. Again, more one-time downloads, but then you can open your browser to http://localhost:8080 to run the application.

More

Learn more about Tapestry Philosophy and then checkout our full Documentation page on which you will find a lot of resources written by committers and contributors.

Obtain Help

Tapestry has an active user mailing list on which you can find a lot of valuable support

[jira] Created: (TAP5-1324) Quickstart should setup a basic Hibernate application using HSQL

2010-10-23 Thread Howard M. Lewis Ship (JIRA)
Quickstart should setup a basic Hibernate application using HSQL


 Key: TAP5-1324
 URL: https://issues.apache.org/jira/browse/TAP5-1324
 Project: Tapestry 5
  Issue Type: Improvement
  Components: quickstart
Reporter: Howard M. Lewis Ship


Most people are building an applicaiton using a database, having the Quickstart 
create a very basic Hibernate-based application (simpler even than the Hotel 
booking demo), maybe a simple todo list, would be great.

Perhaps the right thing to do is to scrap the current quickstart, create a 
quicky project, and experiment with Maven's ability to turna  project into an 
archetype.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.