Submit
Provides an HTML form submission element, <input type="submit">. The Submit component must be enclosed by a Form component. A Submit component is used when a single form has multiple form submission buttons, and the application needs to know which one is the trigger for the form submission.
The application can use two techniques to determine which Submit component (if any) caused the form to be submitted:
- A property may be set to some value; this uses the selected and tag parameters.
- A listener may be notified.
It is even possible to combine the two, in which case the property is set first, then the listener is notified. The listener may be notified immediately (i.e., in the middle of processing the form submission), but by default, the listener will be notified later, just before the form's listener (if any) is notified.
See also: Form, ImageSubmit
Parameters
Name | Type | Direction | Required | Default | Default Binding | Description |
---|---|---|---|---|---|---|
label | String | in | no | literal | The label put on the button (this becomes the HTML value attribute). Alternately, the value attribute may simply be specified as an informal parameter. | |
disabled | boolean | in | no | false | ognl | If set to true, the button will be disabled (will not respond to the mouse); the browser should provide a "greyed out" appearance. |
selected | Object | out | no | ognl | This parameter is bound to a property that is updated when the submit button is clicked by the user. The property is updated to match the tag parameter. | |
tag | Object | in | no | ognl | Tag used with the selected parameter to indicate which Submit button on a form was clicked. | |
listener | IActionListener | in | no | listener | An optional listener (typically specified as the name of a listener method), notified when the Submit is triggered. | |
defer | boolean | in | no | true | ognl | If true (the default), then the listener (if any) will not be notified immediately but will be notified just before the enclosing Form's listener. |
parameters | Object | in | no | ognl |
Parameter(s) gathered at the time the button is triggered,
supplied as listener parameters in the IRequestCycle
available to the listener.
If the parameter is a Collection, it will be converted to an Object array (to match the IRequestCycle getListenerParameters() signature). Allows deferred listeners (defer = true) access to any rewind state not conveniently placed using tag/selected (e.g. when there are multiple objects to select as might happen with a nested Foreach). |
Body: removed
Informal parameters: allowed
Reserved parameters: name, type
Example
<form jwcid="form@Form" listener="doSubmit"> <table> <tr> <th>User name:</th> <td><input jwcid="userName@TextField" value="userName" size="12"/></td> </tr> <tr> <th>Password:</th> <td><input jwcid="password@TextField" value="password" hidden="true" size="12"/></td> </tr> <tr> <td colspan="2"> <input type="submit" value="Login"/> <input type="submit" jwcid="help@Submit" listener="doHelp" value="Help"/> </td> </tr> </table> </form>
Here, the page class will have two listener methods: doHelp() and doSubmit(). doHelp() will be invoked if the user clicks the Help button, then doSubmit() will be invoked either way.