Package org.apache.tapestry5.corelib.base

## Class AbstractField

- java.lang.Object
- - org.apache.tapestry5.corelib.base.AbstractField

- All Implemented Interfaces:
    `ClientElement`, `Field`
  Direct Known Subclasses:
    `AbstractTextField`, `Checkbox`, `Checklist`, `DateField`, `Html5DateField`, `KaptchaField`, `Palette`, `Select`, `Upload`

      @SupportsInformalParameters
      public abstract class AbstractField
      extends java.lang.Object
      implements Field

  Provides initialization of the clientId and elementName properties. In addition, adds the `RenderInformals`, and `DiscardBody` mixins.

  Component Parameters
  Name | Type | Flags | Default | Default Prefix
  --- | --- | --- | --- | ---
  clientId | String |  |  | literal
  Used to explicitly set the client-side id of the element for this component. Normally this is not bound (or null) and org.apache.tapestry5.services.javascript.JavaScriptSupport#allocateClientId(org.apache.tapestry5.ComponentResources) is used to generate a unique client-id based on the component's id. In some cases, when creating client-side behaviors, it is useful to explicitly set a unique id for an element using this parameter. Certain values, such as "submit", "method", "reset", etc., will cause client-side conflicts and are not allowed; using such will cause a runtime exception.
  ensureClientIdUnique | boolean | Since 5.4 |  | prop
  A rarely used option that indicates that the actual client id should start with the clientId parameter (if non-null) but should still pass that Id through org.apache.tapestry5.services.javascript.JavaScriptSupport#allocateClientId(String) to generate the final id. An example of this are the components used inside a org.apache.tapestry5.corelib.components.BeanEditor which will specify a clientId (based on the property name) but still require that it be unique. Defaults to false.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected java.lang.String` | `cssClass` |
    `protected ValidationDecorator` | `decorator` |
    `protected ComponentDefaultProvider` | `defaultProvider` |
    `protected boolean` | `disabled` | If true, then the field will render out with a disabled attribute (to turn off client-side behavior).
    `protected Environment` | `environment` |
    `protected FieldValidationSupport` | `fieldValidationSupport` |
    `protected FormSupport` | `formSupport` |
    `protected JavaScriptSupport` | `javaScriptSupport` |
    `protected java.lang.String` | `label` | The user presentable label for the field.
    `protected Request` | `request` |
    `protected ComponentResources` | `resources` |
    `protected ValidationTracker` | `validationTracker` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `AbstractField()` |

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected void` | `decorateInsideField()` | Invoked from subclasses after they have written their tag and (where appropriate) their informal parameters and have allowed their `Validator` to write markup as well.
    `java.lang.String` | `getClientId()` |
    `java.lang.String` | `getControlName()` |
    `java.lang.String` | `getLabel()` | Returns a user presentable (localized) label for the field, which may be used inside <label> elements on the client, and inside client or server-side validation error messages.
    `boolean` | `isDisabled()` | Returns true if the field is disabled; A disabled field will render a disabled attribute so that it is non-responsive on the client (at least, until its disabled status is changed on the client using JavaScript).
    `boolean` | `isRequired()` | Returns false; most components do not support declarative validation.
    `protected abstract void` | `processSubmission​(java.lang.String controlName)` | Method implemented by subclasses to actually do the work of processing the submission of the form.
    `protected void` | `putPropertyNameIntoBeanValidationContext​(java.lang.String parameterName)` |
    `protected void` | `removePropertyNameFromBeanValidationContext()` |
    `protected void` | `setDecorator​(ValidationDecorator decorator)` |
    `protected void` | `setFormSupport​(FormSupport formSupport)` |

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

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

- - ### Field Detail

    - #### label

          @Parameter(defaultPrefix="literal")
          protected java.lang.String label

      The user presentable label for the field. If not provided, a reasonable label is generated from the component's id, first by looking for a message key named "id-label" (substituting the component's actual id), then by converting the actual id to a presentable string (for example, "userId" to "User Id").

    - #### disabled

          @Parameter("false")
          protected boolean disabled

      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.

    - #### decorator

          @Environmental
          protected ValidationDecorator decorator

    - #### environment

          @Inject
          protected Environment environment

    - #### cssClass

          @Inject
          @Symbol("tapestry.form-field-css-class")
          protected java.lang.String cssClass

    - #### formSupport

          @Environmental(false)
          protected FormSupport formSupport

    - #### javaScriptSupport

          @Environmental
          protected JavaScriptSupport javaScriptSupport

    - #### validationTracker

          @Environmental
          protected ValidationTracker validationTracker

    - #### resources

          @Inject
          protected ComponentResources resources

    - #### defaultProvider

          @Inject
          protected ComponentDefaultProvider defaultProvider

    - #### request

          @Inject
          protected Request request

    - #### fieldValidationSupport

          @Inject
          protected FieldValidationSupport fieldValidationSupport

  - ### Constructor Detail

    - #### AbstractField

          public AbstractField()

  - ### Method Detail

    - #### getLabel

          public final java.lang.String getLabel()

      Description copied from interface: `Field`
      Returns a user presentable (localized) label for the field, which may be used inside <label> elements on the client, and inside client or server-side validation error messages.
      Specified by:
        `getLabel` in interface `Field`
      Returns:
        the label
      See Also:
        `Label`

    - #### getClientId

          public final java.lang.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.

    - #### getControlName

          public final java.lang.String getControlName()

      Specified by:
        `getControlName` in interface `Field`
      Returns:
        the value used as the name attribute of the rendered element. This value will be unique within an enclosing form, even if the same component renders multiple times.
      See Also:
        `FormSupport.allocateControlName(String)`

    - #### isDisabled

          public final boolean isDisabled()

      Description copied from interface: `Field`
      Returns true if the field is disabled; A disabled field will render a disabled attribute so that it is non-responsive on the client (at least, until its disabled status is changed on the client using JavaScript). A disabled field will ignore any value passed up in a form submit request. Care must be taken if the disabled status of a field can change between the time the field is rendered and the time the enclosing form is submitted.
      Specified by:
        `isDisabled` in interface `Field`
      Returns:
        true if disabled, false otherwise

    - #### processSubmission

          protected abstract void processSubmission​(java.lang.String controlName)

      Method implemented by subclasses to actually do the work of processing the submission of the form. The element's controlName property will already have been set. This method is only invoked if the field is not `disabled`.
      Parameters:
        `controlName` - the control name of the rendered element (used to find the correct parameter in the request)

    - #### decorateInsideField

          protected final void decorateInsideField()

      Invoked from subclasses after they have written their tag and (where appropriate) their informal parameters and have allowed their `Validator` to write markup as well.

    - #### setDecorator

          protected final void setDecorator​(ValidationDecorator decorator)

    - #### setFormSupport

          protected final void setFormSupport​(FormSupport formSupport)

    - #### isRequired

          public boolean isRequired()

      Returns false; most components do not support declarative validation.
      Specified by:
        `isRequired` in interface `Field`
      Returns:
        true if a non-blank value is required for the field

    - #### putPropertyNameIntoBeanValidationContext

          protected void putPropertyNameIntoBeanValidationContext​(java.lang.String parameterName)

    - #### removePropertyNameFromBeanValidationContext

          protected void removePropertyNameFromBeanValidationContext()