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 Summary
Fields Modifier and Type Field Description static StringOPT_CONSTRAINT_TYPE_DATEstatic StringOPT_CONSTRAINT_TYPE_EMAILstatic StringOPT_CONSTRAINT_TYPE_NAMEstatic StringOPT_CONSTRAINT_TYPE_NUMERICstatic StringPROP_CONSTRAINT_MESSAGEstatic StringPROP_CONSTRAINT_TYPEstatic StringPROP_DEFAULT_VALUEstatic StringPROP_DESCRIPTIONstatic StringPROP_ELEMENT_NAMEstatic StringPROP_HIDE_TITLEstatic StringPROP_REQUIREDstatic StringPROP_REQUIRED_MESSAGEstatic StringPROP_STYLING_CSSstatic StringPROP_TITLE-
Fields inherited from class com.adobe.cq.testing.client.components.AbstractComponent
changeProperties, client, componentPath, DEFAULT_LOCATION, jsonNode, location, pagePath
-
-
Constructor Summary
Constructors Constructor Description AbstractFormFieldComponent(ComponentClient client, String pagePath, String location, String nameHint)The constructor stores all the component path information like parentPage, name etc.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.sling.testing.clients.util.FormEntityBuildergetCreateFormEntity(String order)Returns the FormEntityBuilder used for the create request inAbstractComponent.create(String,int...).StringgetElementName()Get the elements name.voidsetConstraint(String requiredMessage, String constraintMessage, String constraintType)Configures the constraint that should apply to this form field.voidsetDefaultValue(String defaultValue)Set the default value for a form field.voidsetDescription(String description)Set the description for the text input fieldvoidsetElementName(String elementName)Set the name of the form field element.voidsetHideTitle(boolean hideTitle)Defines if the title for this form field should be shown or not.voidsetStylingCss(String css)Sets the CSS value on the Styling tab for this form field.voidsetTitle(String title)Sets the title to be shown for this form field.voidsetUseConstraint(boolean useConstraints)Defines if constraints should be applied to this field or not-
Methods inherited from class com.adobe.cq.testing.client.components.AbstractComponent
create, getClient, getComponentNode, getComponentPath, getFirstChild, getLocation, getName, getNext, getNextNodePath, getPagePath, getParentPath, getPrevious, getPreviousNodePath, getProperty, getPropertyAsString, getPropertyAsStringArray, getResourceType, reorder, save, setProperty, setProperty
-
-
-
-
Field Detail
-
PROP_DESCRIPTION
public static final String PROP_DESCRIPTION
- See Also:
- Constant Field Values
-
PROP_TITLE
public static final String PROP_TITLE
- See Also:
- Constant Field Values
-
PROP_HIDE_TITLE
public static final String PROP_HIDE_TITLE
- See Also:
- Constant Field Values
-
PROP_ELEMENT_NAME
public static final String PROP_ELEMENT_NAME
- See Also:
- Constant Field Values
-
PROP_DEFAULT_VALUE
public static final String PROP_DEFAULT_VALUE
- See Also:
- Constant Field Values
-
PROP_REQUIRED
public static final String PROP_REQUIRED
- See Also:
- Constant Field Values
-
PROP_REQUIRED_MESSAGE
public static final String PROP_REQUIRED_MESSAGE
- See Also:
- Constant Field Values
-
PROP_CONSTRAINT_TYPE
public static final String PROP_CONSTRAINT_TYPE
- See Also:
- Constant Field Values
-
PROP_CONSTRAINT_MESSAGE
public static final String PROP_CONSTRAINT_MESSAGE
- See Also:
- Constant Field Values
-
OPT_CONSTRAINT_TYPE_DATE
public static final String OPT_CONSTRAINT_TYPE_DATE
- See Also:
- Constant Field Values
-
OPT_CONSTRAINT_TYPE_EMAIL
public static final String OPT_CONSTRAINT_TYPE_EMAIL
- See Also:
- Constant Field Values
-
OPT_CONSTRAINT_TYPE_NAME
public static final String OPT_CONSTRAINT_TYPE_NAME
- See Also:
- Constant Field Values
-
OPT_CONSTRAINT_TYPE_NUMERIC
public static final String OPT_CONSTRAINT_TYPE_NUMERIC
- See Also:
- Constant Field Values
-
PROP_STYLING_CSS
public static final String PROP_STYLING_CSS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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. TheAbstractComponent.getName()method will return the correct name after(order,int...)has been called.
-
-
Method Detail
-
getCreateFormEntity
public org.apache.sling.testing.clients.util.FormEntityBuilder getCreateFormEntity(String order)
Description copied from class:AbstractComponentReturns the FormEntityBuilder used for the create request inAbstractComponent.create(String,int...). This method can be overridden in a subclass to extend the parameters that need to sent with the creation request.- Overrides:
getCreateFormEntityin classAbstractComponent- Parameters:
order- Defines where the component should be added in relation to its siblings. Possible values arefirst,last,before [nodeName],after [nodeName].- Returns:
- An FormEntityBuilder with
_charset_,./sling:resourceTypeand:nameHintset.
-
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 usesetUseConstraint(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 fieldconstraintMessage- The error message shown when the contstraint check failsconstraintType- 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
-
-