org.apache.tapestry5.corelib.components

## Class Submit

- java.lang.Object
- - org.apache.tapestry5.corelib.components.Submit

- All Implemented Interfaces:
    ClientElement

      @SupportsInformalParameters
       @Events(value="selected by default, may be overridden")
       @Import(module="t5/core/forms")
      public class Submit
      extends Object
      implements ClientElement

  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, by default, and has no context.

  Component Parameters
  Name | Type | Flags | Default | Default Prefix
  --- | --- | --- | --- | ---
  class | String | Since 5.4 | message:private-core-components.submit.class | literal
  CSS class for the element.
  context | Object | Since 5.1.0.0 |  | prop
  The list of values that will be made available to event handler method of this component when the form is submitted.
  defer | boolean |  |  | 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). In general, this can be left as the default except when the Submit component is rendering inside a org.apache.tapestry5.corelib.components.Loop, in which case defer should be bound to false (otherwise, the event context will always be the final value of the Loop).
  disabled | boolean |  | false | prop
  If true, then the field will render out with a disabled attribute (to turn off client-side behavior). When the form is submitted, the bound value is evaluated again and, if true, the field's value is ignored (not even validated) and the component's events are not fired.
  event | String | Not Null |  | literal
  The name of the event that will be triggered if this component is the cause of the form submission. The default is org.apache.tapestry5.EventConstants#SELECTED.
  image | org.apache.tapestry5.Asset | Since 5.1.0.0 |  | asset
  If provided, the component renders an input tag with type "image". Otherwise "submit".
  mode | org.apache.tapestry5.corelib.SubmitMode | Not Null, Since 5.2.0 |  | literal
  Defines the mode, or client-side behavior, for the submit. The default is org.apache.tapestry5.corelib.SubmitMode#NORMAL; clicking the button submits the form with validation. org.apache.tapestry5.corelib.SubmitMode#CANCEL indicates the form should be submitted as a cancel, with no client-side validation. org.apache.tapestry5.corelib.SubmitMode#UNCONDITIONAL bypasses client-side validation, but does not indicate that the form was cancelled.

  Component Events
  Name | Description
  --- | ---
  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;

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

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Submit()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getClientId()` Returns the component's client id.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Submit

          public Submit()

  - ### Method Detail

    - #### getClientId

          public String getClientId()

      Returns the component's client id. This must be called after the component has rendered.
      Specified by:
        `getClientId` in interface `ClientElement`
      Returns:
        client id for the component

${project.version} - Copyright © 2003-2015 The Apache Software Foundation.