Class AbstractFormFieldComponent

java.lang.Object
com.adobe.cq.testing.client.components.AbstractComponent
com.adobe.cq.testing.client.components.foundation.form.AbstractFormFieldComponent
Direct Known Subclasses:
Address, Captcha, Checkbox, Creditcard, Dropdown, FileUpload, Hidden, ImageButton, ImageUpload, Password, RadioGroup, Text

public abstract class AbstractFormFieldComponent extends AbstractComponent
This abstract class defines common Methods and Constants for all form fields. Please note that on individual level components may have some of this defaults removed (e.g captcha has no element name), or modified (e.g. more Styling values). Then either extend the methods of this class by overriding or add component specific methods.
  • Field Details

  • Constructor Details

    • AbstractFormFieldComponent

      public AbstractFormFieldComponent(ComponentClient client, String pagePath, String location, String nameHint)
      The constructor stores all the component path information like parentPage, name etc.
      Parameters:
      client - The ComponentClient that will be used for sending the requests.
      pagePath - path to the page that will contain the component.
      location - relative location to the parent node inside the page that will contain the component node.
      nameHint - name to be used for the component node. Might get altered by the server if a naming conflict occurs. The AbstractComponent.getName() method will return the correct name after (order,int...) has been called.
  • Method Details

    • getCreateFormEntity

      public org.apache.sling.testing.clients.util.FormEntityBuilder getCreateFormEntity(String order)
      Description copied from class: AbstractComponent
      Returns the FormEntityBuilder used for the create request in AbstractComponent.create(String,int...). This method can be overridden in a subclass to extend the parameters that need to sent with the creation request.
      Overrides:
      getCreateFormEntity in class AbstractComponent
      Parameters:
      order - Defines where the component should be added in relation to its siblings. Possible values are first, last, before [nodeName], after [nodeName].
      Returns:
      An FormEntityBuilder with _charset_,./sling:resourceType and :nameHint set.
    • setElementName

      public void setElementName(String elementName)
      Set the name of the form field element.
      Parameters:
      elementName - element name to be set.
    • getElementName

      public String getElementName()
      Get the elements name.
      Returns:
      the element name
    • setDefaultValue

      public void setDefaultValue(String defaultValue)
      Set the default value for a form field. The default implementation only sets '"defaultValue"'. If extended component has more default fields (or none) either override this method or create new one.
      Parameters:
      defaultValue - the default string value to be set for this form field
    • setUseConstraint

      public void setUseConstraint(boolean useConstraints)
      Defines if constraints should be applied to this field or not
      Parameters:
      useConstraints - true to apply defined constraint, otherwise false
    • setConstraint

      public void setConstraint(String requiredMessage, String constraintMessage, String constraintType)
      Configures the constraint that should apply to this form field. to enable/disable the constraint use setUseConstraint(boolean). This is the default implementation. If the extended form field has more or less fields either override this method or create a new one.
      Parameters:
      requiredMessage - The message that describes whats expected for this field
      constraintMessage - The error message shown when the contstraint check fails
      constraintType - what type of constraint it is. Constraints are implemented as components. e.g. OPT_CONSTRAINT_TYPE_EMAIL ("foundation/components/form/constraints/email").
    • setStylingCss

      public void setStylingCss(String css)
      Sets the CSS value on the Styling tab for this form field.
      Parameters:
      css - css value
    • setDescription

      public void setDescription(String description)
      Set the description for the text input field
      Parameters:
      description - The description text
    • setTitle

      public void setTitle(String title)
      Sets the title to be shown for this form field.
      Parameters:
      title - title text.
    • setHideTitle

      public void setHideTitle(boolean hideTitle)
      Defines if the title for this form field should be shown or not.
      Parameters:
      hideTitle - true to hide the title, otherwise false