org.apache.tapestry5.corelib.components.Submit

Corresponds to input type="submit" or input type="image", 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.

[JavaDoc]

Component Parameters

NameTypeFlagsDefaultDefault PrefixSinceDescription
contextObjectNOT Allow Nullprop5.1.0.0The list of values that will be made available to event handler method of this component when the form is submitted.
deferbooleanNOT Allow NullpropIf true (the default), then any notification sent by the component will be deferred until the end of the form submission (this is usually desirable).
disabledbooleanNOT Allow NullfalsepropIf 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.
eventStringNOT Allow NullliteralThe name of the event that will be triggered if this component is the cause of the form submission. The default is "selected".
imageAssetNOT Allow Nullasset5.1.0.0If provided, the component renders an input tag with type "image". Otherwise "submit".

Informal parameters: supported

Component Events

  • selected: by default, may be overridden

Examples

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.

EditUser.tml

<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>

EditUser.java

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; }
}

Back to index