|
|
|
Description
A component that manages a HTML <form>. The other form-related
components must be wrapped inside the Form.
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.
|
See Also
Button,
Checkbox,
FieldLabel,
Hidden,
ImageSubmit,
ListEdit,
Option,
PropertySelection,
Radio,
RadioGroup,
Submit,
TextArea,
TextField,
Upload,
ValidField
|
Parameters
Name |
Type |
Direction |
Required |
Default |
Description |
listener |
IActionListener
|
in |
no |
|
The listener, informed after the wrapped components of the form
have had a chance to process their portion the request.
|
delegate |
IValidationDelegate
|
in |
no |
|
Object used to assist in error tracking and reporting. A single
instance is shared by all ValidField and
FieldLabel comopnents within a single form.
|
stateful |
boolean |
in |
no |
true |
If true (the default), then the component requires an active
(i.e., non-new) HttpSession when triggered. Failing that, it throws a
StaleLinkException.
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.
|
direct |
boolean |
in |
no |
true |
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.
|
method |
String |
in |
no |
POST |
The value to use for the method attribute of the <form> tag.
|
Body: rendered Informal parameters:
allowed
Reserved
parameters: none
|
Examples
The Form component is used to provide a simple login page.
<form jwcid="@Form" listener="ognl:listeners.formSubmit">
<table cellpadding="4">
<tr><td>Username:</td><td><input jwcid="@TextField" value="ognl:visit.username" size="12"/></td>
</tr>
<tr><td>Password:</td><td><input jwcid="@TextField" 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;
}
}
|
|