Sample page file
Sample jwc file
Component java class
- If there is a parameter that needs to be accessed by a java class in a component, leave the parameter out of the jwc file and include this in the java class:
Goto a new page
| Warning A PageRedirectException cannot be used inside a pageBeginRender method. |
| Warning If you have a listener attached to the form submit and have listeners on the buttons, a redirect in the button listeners will prevent the form submit listener from being called. |
Set a variable on a new page and goto it
- Get the page directly and programmatically set the variable:
- Use an external link, allows the parameter to be part of url.
- Be careful, only use primatives and not too many of them.
- Listener should implement IExternalPage and looks like:
- Redirected page looks like:
Using annotations to get properties
Validation: Simple required field
| Warning If you have a listener attached to the form submit and have listeners on the buttons, a redirect in the button listeners will prevent the form submit listener from being called. |
Validation: Advanced validation
Validation: pre-rendered errors
- To display an error message when a page is being displayed for the first time.
Listeners
There are several different ways to use listeners.
As the part of a DirectLink, using either an 'ognl:listeners.' or 'listener:' notation:
As the default form listener:
| If you use multiple parameters on a method, do not use an Object[]. Rather, specify them explicitly in the listener method signature. |
Commonly overriden methods
Protected Page
The page class (or it's base class) must implement PageValidateListener and the method pageValidate() setup to redirect (usually throw a PageRedirectException) to a login page if not authenticated.
If logic in html
Any logic in the html page must be replaced with entities. Furthermore, the ognl: is only required for the opening of the condition.
Using ognl variables in javascript call
To mix an ognl expression in a javascript call, the expression must be part of a jwcid element and the expression itself must start with ognl.
Clearing a form using ognl variables in a javascript call
Tapestry will override any form id if there are multiple forms on a page, relying on Form0 is not safe.
Instead use ognl in the javascript to explicitly refer to the component id.
Date formatting
Using a property to format the display of a date.
Persisting data
Redirect after post
- Alternatively, use getPageService():
Zebra stripes on a table
Using a Render Block with a If Else
Using properties
- The raw="true" will insert the properties without translating values.
Credit and Thanks
Michael Prescott
Dave Park
