Package org.apache.tapestry5.corelib.internal

## Class FormSupportImpl

- java.lang.Object
- - org.apache.tapestry5.corelib.internal.FormSupportImpl

- All Implemented Interfaces:
    `ClientElement`, `Locatable`, `InternalFormSupport`, `FormSupport`

      public class FormSupportImpl
      extends Object
      implements InternalFormSupport, Locatable

  Provides support to components enclosed by a form when the form is rendering (allowing the components to registry form submit callback commands), and also during form submission time. TODO: Most methods should only be invokable depending on whether the form is rendering or processing a submission.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `FormSupportImpl​(ComponentResources resources, String formValidationId)` | Constructor used when processing a form submission.
    `FormSupportImpl​(ComponentResources resources, String clientId, ComponentActionSink actionSink, boolean clientValidationEnabled, IdAllocator idAllocator, String formValidationId)` | Full constructor (specifically constructor for render time).

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addValidation​(Field field, String validationName, String message, Object constraint)` | Collects field validation information.
    `String` | `allocateControlName​(String id)` | Allocates a unique (within the form) control name for some enclosed component, based on the component's id.
    `void` | `defer​(Runnable command)` | Defers a command until the end of the form submission.
    `void` | `executeDeferred()` | Executes any deferred callbacks added via `FormSupport.defer(Runnable)`.
    `String` | `getClientId()` |
    `String` | `getEncodingType()` | Returns the form encoding type, if one has been set via a call to `FormSupport.setEncodingType(String)`.
    `String` | `getFormComponentId()` | Returns the complete id of the underlying Form component.
    `String` | `getFormValidationId()` | Id used as a prefix when searching `Messages` for validation messages and constraints.
    `Location` | `getLocation()` | Returns the location associated with this object for error reporting purposes.
    `boolean` | `isClientValidationEnabled()` | Return true if client validation is enabled for this form, false otherwise.
    `void` | `setEncodingType​(String encodingType)` | Sets the encoding type for the Form.
    `<T> void` | `store​(T component, ComponentAction<T> action)` | Stores an action for execution during a later request.
    `<T> void` | `storeAndExecute​(T component, ComponentAction<T> action)` | As with `FormSupport.store(Object, org.apache.tapestry5.ComponentAction)`}, but the action is also invoked immediately.
    `<T> void` | `storeCancel​(T component, ComponentAction<T> action)` | Stores an action for execution in a later request when the containing form is canceled.

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

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

- - ### Constructor Detail

    - #### FormSupportImpl

          public FormSupportImpl​(ComponentResources resources,
                                 String formValidationId)

      Constructor used when processing a form submission.

    - #### FormSupportImpl

          public FormSupportImpl​(ComponentResources resources,
                                 String clientId,
                                 ComponentActionSink actionSink,
                                 boolean clientValidationEnabled,
                                 IdAllocator idAllocator,
                                 String formValidationId)

      Full constructor (specifically constructor for render time).

  - ### Method Detail

    - #### getLocation

          public Location getLocation()

      Description copied from interface: `Locatable`
      Returns the location associated with this object for error reporting purposes.
      Specified by:
        `getLocation` in interface `Locatable`

    - #### getFormComponentId

          public String getFormComponentId()

      Description copied from interface: `FormSupport`
      Returns the complete id of the underlying Form component.
      Specified by:
        `getFormComponentId` in interface `FormSupport`

    - #### allocateControlName

          public String allocateControlName​(String id)

      Description copied from interface: `FormSupport`
      Allocates a unique (within the form) control name for some enclosed component, based on the component's id.
      Specified by:
        `allocateControlName` in interface `FormSupport`
      Parameters:
        `id` - the component's id
      Returns:
        a unique string, usually the component's id, but sometime extended with a unique number or string

    - #### store

          public <T> void store​(T component,
                                ComponentAction<T> action)

      Description copied from interface: `FormSupport`
      Stores an action for execution during a later request. If the action contains any mutable state, it should be in its final state before invoking this method and its internal state should not be changed subsequently.
      Specified by:
        `store` in interface `FormSupport`

    - #### storeCancel

          public <T> void storeCancel​(T component,
                                      ComponentAction<T> action)

      Description copied from interface: `FormSupport`
      Stores an action for execution in a later request when the containing form is canceled. Cancel actions are triggered before the form fires its `EventConstants.CANCELED` event.
      Specified by:
        `storeCancel` in interface `FormSupport`

    - #### storeAndExecute

          public <T> void storeAndExecute​(T component,
                                          ComponentAction<T> action)

      Description copied from interface: `FormSupport`
      As with `FormSupport.store(Object, org.apache.tapestry5.ComponentAction)`}, but the action is also invoked immediately. This is useful for defining an action that should occur symmetrically in both the render request and the form submission's action request.
      Specified by:
        `storeAndExecute` in interface `FormSupport`
      Parameters:
        `component` - component against which to trigger the action
        `action` - the action that will be triggered (and passed the component)

    - #### defer

          public void defer​(Runnable command)

      Description copied from interface: `FormSupport`
      Defers a command until the end of the form submission. The command will be executed before the Form's validate notification, but after all other submit actions for the form have been processed. This is used, primarily, to coordinate validations or other operations that involve multiple components, when the order of the components can not be determined. During a form render, runnables are executed after the body of the form has rendered.
      Specified by:
        `defer` in interface `FormSupport`
      Parameters:
        `command` - to be executed

    - #### executeDeferred

          public void executeDeferred()

      Description copied from interface: `InternalFormSupport`
      Executes any deferred callbacks added via `FormSupport.defer(Runnable)`.
      Specified by:
        `executeDeferred` in interface `InternalFormSupport`

    - #### getClientId

          public String getClientId()

      Specified by:
        `getClientId` in interface `ClientElement`
      Returns:
        a unique id for the element. This value will be unique for any given rendering of a page. This value is intended for use as the id attribute of the client-side element, and will be used with any DHTML/Ajax related JavaScript.

    - #### getEncodingType

          public String getEncodingType()

      Description copied from interface: `InternalFormSupport`
      Returns the form encoding type, if one has been set via a call to `FormSupport.setEncodingType(String)`.
      Specified by:
        `getEncodingType` in interface `InternalFormSupport`

    - #### setEncodingType

          public void setEncodingType​(String encodingType)

      Description copied from interface: `FormSupport`
      Sets the encoding type for the Form. This should only be set once, and if
      Specified by:
        `setEncodingType` in interface `FormSupport`
      Parameters:
        `encodingType` - MIME type indicating type of encoding for the form

    - #### addValidation

          public void addValidation​(Field field,
                                    String validationName,
                                    String message,
                                    Object constraint)

      Description copied from interface: `FormSupport`
      Collects field validation information. A Form may turn off client-side validation, in which case these calls will be ignored.
      Specified by:
        `addValidation` in interface `FormSupport`
      Parameters:
        `field` - for which validation is being generated
        `validationName` - name of validation method (see Tapestry.Validation in tapestry.js)
        `message` - the error message to display if the field is invalid
        `constraint` - additional constraint value, or null for validations that don't require a constraint

    - #### isClientValidationEnabled

          public boolean isClientValidationEnabled()

      Description copied from interface: `FormSupport`
      Return true if client validation is enabled for this form, false otherwise.
      Specified by:
        `isClientValidationEnabled` in interface `FormSupport`

    - #### getFormValidationId

          public String getFormValidationId()

      Description copied from interface: `FormSupport`
      Id used as a prefix when searching `Messages` for validation messages and constraints. This is normally the simple id of the form.
      Specified by:
        `getFormValidationId` in interface `FormSupport`
      Returns:
        validation id string
      See Also:
        `FieldTranslatorSource`, `FieldValidatorSource`