| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| <!-- $Id$ --> |
| <html> |
| <head> |
| <title>Form</title> |
| <link rel="stylesheet" type="text/css" href="Tapestry.css" title="style"> |
| </head> |
| |
| <body> |
| <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| <tr> |
| <td align="left"><A href="Foreach.html"><IMG alt=Foreach src="common-images/prev.png"></a></td> |
| <td align="middle"><A href="index.html"><IMG alt="Component Index" src="common-images/home.png" ></a></td> |
| <td align="right"><A href="Frame.html"><IMG alt=Frame src="common-images/next.png"></a></td> |
| <tr> |
| <tr> |
| <td colspan="3"><hr></td> |
| </tr> |
| <tr> |
| <td colspan="3"> |
| <table border="0" cellpadding="4" cellspacing="4" width="100%"> |
| |
| <tr valign="top"> |
| <td> |
| <table> |
| <tr> |
| <td><font size="+2"><b>Form</b></font></td> |
| </tr> |
| <tr> |
| <td> |
| <A href="../api/org/apache/tapestry/form/Form.html"> |
| org.apache.tapestry.form.Form</a> |
| </td> |
| </tr> |
| </table> |
| </td> |
| <td> |
| <table align="right" valign="middle" bgcolor="#c0c0c0" cellpadding="8"> |
| <tr> |
| <td>Non Visual Component</td> |
| </tr> |
| </table> |
| </td> |
| </tr> |
| |
| <tr valign="center"> |
| <td colspan="2"> </td> |
| </tr> |
| |
| <tr> |
| <td colspan="2"> |
| <b>Description</b> |
| <br> |
| A component that manages a HTML <form>. The other form-related |
| components must be wrapped inside the Form. |
| <p> |
| When a form is submitted, it continues |
| through the rewind cycle until after all of its wrapped elements |
| have renderred. As the form component render (in the rewind cycle), |
| they will be updating properties of the containing page and |
| notifying thier listeners. Again: each form component is responsible |
| not only for rendering HTML (to present the form), but for handling |
| it's share of the form submission. Only after all that is done will |
| the Form notify its listener.</p> |
| |
| </td> |
| </tr> |
| |
| <tr> |
| <td colspan="2"> |
| <b>See Also</b> |
| <br> |
| <A href="Button.html">Button</A>, |
| <A href="Checkbox.html">Checkbox</a>, |
| <A href="FieldLabel.html">FieldLabel</a>, |
| <A href="Hidden.html">Hidden</a>, |
| <A href="ImageSubmit.html">ImageSubmit</a>, |
| <A href="ListEdit.html">ListEdit</a>, |
| <A href="Option.html">Option</a>, |
| <A href="PropertySelection.html">PropertySelection</a>, |
| <A href="Radio.html">Radio</a>, |
| <A href="RadioGroup.html">RadioGroup</a>, |
| <A href="Submit.html">Submit</a>, |
| <a href="TextArea.html">TextArea</a>, |
| <A href="TextField.html">TextField</a>, |
| <A href="Upload.html">Upload</a>, |
| <A href="ValidField.html">ValidField</a> |
| </td> |
| </tr> |
| |
| <tr> |
| <td colspan="2"> |
| <b>Parameters</b> |
| <br> |
| <table border="1" cellpadding="4" cellspacing="4" class="parameters"> |
| <tr> |
| <th>Name</th> |
| <th>Type</th> |
| <th>Direction</th> |
| <th>Required</th> |
| <th>Default</th> |
| <th>Description</th> |
| </tr> |
| <tr> |
| <td>listener</td> |
| <td> |
| <A href="../api/org/apache/tapestry/IActionListener.html"><tt>IActionListener</tt></a> |
| </td> |
| <td>in</td> |
| <td>no</td> |
| <td> </td> |
| <td>The listener, informed <u>after</u> the wrapped components of the form |
| have had a chance to process their portion the request. |
| </td> |
| </tr> |
| <tr> |
| <td>delegate</td> |
| <td><A href="../api/org/apache/tapestry/valid/IValidationDelegate.html"><tt>IValidationDelegate</tt></a> |
| </td> |
| <td>in</td> |
| <td>no</td> |
| <td> </td> |
| <td>Object used to assist in error tracking and reporting. A single |
| instance is shared by all <a href="ValidField.html">ValidField</a> and |
| <a href="FieldLabel.html">FieldLabel</a> comopnents within a single form. |
| </td> |
| </tr> |
| <tr> |
| <td>stateful</td> |
| <td>boolean</td> |
| <td>in</td> |
| <td>no</td> |
| <td>true</td> |
| <td>If true (the default), then the component requires an active |
| (i.e., non-new) HttpSession when triggered. Failing that, it throws a |
| <A href="../api/org/apache/tapestry/StaleLinkException.html"><tt>StaleLinkException</tt></a>. |
| If false, then no check is necessary. |
| Generally, forms are stateful, but it is possible to put a stateless form |
| onto the Home page of an application. |
| </td> |
| </tr> |
| <tr> |
| <td>direct</td> |
| <td>boolean</td> |
| <td>in</td> |
| <td>no</td> |
| <td>true</td> |
| <td>If true (the default), then the direct service is used for the form. |
| This decreases the amount of work required to process the form submission, |
| and is acceptible for most forms, even those that contain Foreaches (but |
| not those that are inside a Foreach). An abbreviated form of the rewind |
| cycle takes place, that only references the form and the components it wraps. |
| </td> |
| </tr> |
| <tr> |
| <td>method</td> |
| <td>String</td> |
| <td>in</td> |
| <td>no</td> |
| <td>POST</td> |
| <td>The value to use for the method attribute of the <form> tag. |
| </td> |
| </tr> |
| </table> |
| <P>Body: <STRONG>rendered</STRONG><BR>Informal parameters: |
| <STRONG>allowed</STRONG> |
| <br> |
| Reserved |
| parameters: <EM>none</EM> </P> |
| |
| </td> |
| </tr> |
| |
| <tr> |
| <td colspan="2"> |
| <b>Examples</b> |
| <p> |
| The Form component is used to provide a simple login page. |
| <p> |
| |
| <table class="examples" cellpadding="4"> |
| <form> |
| <tr> |
| <td>Username:</td><td><input size="12"></td> |
| </tr> |
| <tr> |
| <td>Password:</td><td><input type="password" size="12"></td> |
| </tr> |
| <tr align="right"> |
| <td colspan="2"><input type="submit" value="Login"></td> |
| </tr> |
| </form> |
| </table> |
| |
| <pre> |
| <form jwcid="<span class="jwcid">@<a href="Form.html">Form</a></span>" listener="ognl:listeners.formSubmit"> |
| <table cellpadding="4"> |
| <tr><td>Username:</td><td><input jwcid="@<a href="TextField.html">TextField</a>" value="ognl:visit.username" size="12"/></td> |
| </tr> |
| <tr><td>Password:</td><td><input jwcid="@<a href="TextField.html">TextField</a>" value="ognl:visit.password" hidden="ognl:true" size="12"/></td> |
| </tr> |
| <tr align="right"> |
| <td colspan="2"><input type="submit" value="Login"/></td> |
| </tr> |
| </table> |
| </form> |
| |
| |
| |
| public class LoginPage extends BasePage { |
| |
| public void formSubmit(IRequestCycle cycle) { |
| Visit visit = (Visit) getVisit(); |
| |
| if (visit.isAuthenticated()) { |
| cycle.activate("Home"); |
| } |
| } |
| } |
| |
| public class Visit() implements Serializable { |
| private username; |
| private password; |
| |
| public getUsername() { return username; } |
| |
| public setUsername(String value) { |
| username = value; |
| } |
| |
| public getPassword() { return password; } |
| |
| public setPassword(String value) { |
| password = value; |
| } |
| |
| public boolean isAuthenticated() { |
| // Some authentication code. |
| return true; |
| } |
| } |
| </pre> |
| </td></tr> |
| </table></TD></TR> |
| <tr> |
| <td colspan="3"><hr></td> |
| </tr> |
| <tr> |
| <td align="left"><A href="Foreach.html"><IMG alt=Foreach src="common-images/prev.png"></a></td> |
| <td align="middle"><A href="index.html"><IMG alt="Component Index" src="common-images/home.png" ></a></td> |
| <td align="right"><A href="Frame.html"><IMG alt=Frame src="common-images/next.png"></a></td> |
| </tr></TABLE> |
| |
| </body> |
| </html> |