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 Object implements Field
Provides initialization of the clientId and elementName properties. In addition, adds the RenderInformals, and DiscardBody mixins.
Component Parameters 
NameTypeFlagsDefaultDefault Prefix
clientIdString  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.
ensureClientIdUniquebooleanSince 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 Details

  • Constructor Details

  • Method Details

    • getLabel

      public final 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:
    • getClientId

      public final 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 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:
    • 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(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(String parameterName)
    • removePropertyNameFromBeanValidationContext