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 String
OPT_CONSTRAINT_TYPE_DATE
static String
OPT_CONSTRAINT_TYPE_EMAIL
static String
OPT_CONSTRAINT_TYPE_NAME
static String
OPT_CONSTRAINT_TYPE_NUMERIC
static String
PROP_CONSTRAINT_MESSAGE
static String
PROP_CONSTRAINT_TYPE
static String
PROP_DEFAULT_VALUE
static String
PROP_DESCRIPTION
static String
PROP_ELEMENT_NAME
static String
PROP_HIDE_TITLE
static String
PROP_REQUIRED
static String
PROP_REQUIRED_MESSAGE
static String
PROP_STYLING_CSS
static String
PROP_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.FormEntityBuilder
getCreateFormEntity(String order)
Returns the FormEntityBuilder used for the create request inAbstractComponent.create(String,int...)
.String
getElementName()
Get the elements name.void
setConstraint(String requiredMessage, String constraintMessage, String constraintType)
Configures the constraint that should apply to this form field.void
setDefaultValue(String defaultValue)
Set the default value for a form field.void
setDescription(String description)
Set the description for the text input fieldvoid
setElementName(String elementName)
Set the name of the form field element.void
setHideTitle(boolean hideTitle)
Defines if the title for this form field should be shown or not.void
setStylingCss(String css)
Sets the CSS value on the Styling tab for this form field.void
setTitle(String title)
Sets the title to be shown for this form field.void
setUseConstraint(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:AbstractComponent
Returns 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:
getCreateFormEntity
in 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: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 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
-
-