Corresponds to input type="submit", a client-side element that can force the enclosing form to submit. The submit responsible for the form submission will post a notification that allows the application to know that it was the responsible entity. The notification is named "selected" and has no context.
| Name | Type | Flags | Default | Default Prefix | Description |
|---|---|---|---|---|---|
| defer | boolean | NOT Allow Null | prop | If true (the default), then any notification sent by the component will be deferred until the end of the form submission (this is usually desirable). | |
| disabled | boolean | NOT Allow Null | false | prop | If true, then the field will render out with a disabled attribute (to turn off client-side behavior). Further, a disabled field ignores any value in the request when the form is submitted. |
| event | String | NOT Allow Null | literal | The name of the event that will be triggered if this component is the cause of the form submission. The default is "selected". |
Informal parameters: supported
The thing to remember is that the Submit component will trigger its "selected" event in the middle of the form submission, before the form triggers its "validate", "success" (or "failure") and "submit" events. Thus the best thing to do is to store in a temporary field what should be done inside the "success" event handler.
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<body>
<h1>Edit User</h1>
<t:form>
<t:errors/>
<t:beaneditor t:id="user"/>
<p>
<input type="submit" value="Update User"/>
<t:submit t:id="delete" value="Delete User"/>
</p>
</t:form>
</html>
public class EditUser
{
@Inject
private UserDAO _userDAO;
@Persist
private User _user;
private boolean _deleteUser;
void onSelectedFromDelete() { _deleteUser = true; }
Object onSuccess()
{
if (_deleteUser)
_userDAO.delete(user.getId());
else
_userDAO.update(user);
return UserList.class;
}
public void setUser(User user) { _user = user; }
public User getUser() { return _user; }
}