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
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
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from class com.adobe.cq.testing.client.components.AbstractComponent
changeProperties, client, componentPath, DEFAULT_LOCATION, jsonNode, location, pagePath
-
Constructor Summary
ConstructorDescriptionAbstractFormFieldComponent
(ComponentClient client, String pagePath, String location, String nameHint) The constructor stores all the component path information like parentPage, name etc. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.sling.testing.clients.util.FormEntityBuilder
getCreateFormEntity
(String order) Returns the FormEntityBuilder used for the create request inAbstractComponent.create(String,int...)
.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
Sets the title to be shown for this form field.void
setUseConstraint
(boolean useConstraints) Defines if constraints should be applied to this field or notMethods 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 Details
-
PROP_DESCRIPTION
- See Also:
-
PROP_TITLE
- See Also:
-
PROP_HIDE_TITLE
- See Also:
-
PROP_ELEMENT_NAME
- See Also:
-
PROP_DEFAULT_VALUE
- See Also:
-
PROP_REQUIRED
- See Also:
-
PROP_REQUIRED_MESSAGE
- See Also:
-
PROP_CONSTRAINT_TYPE
- See Also:
-
PROP_CONSTRAINT_MESSAGE
- See Also:
-
OPT_CONSTRAINT_TYPE_DATE
- See Also:
-
OPT_CONSTRAINT_TYPE_EMAIL
- See Also:
-
OPT_CONSTRAINT_TYPE_NAME
- See Also:
-
OPT_CONSTRAINT_TYPE_NUMERIC
- See Also:
-
PROP_STYLING_CSS
- See Also:
-
-
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. TheAbstractComponent.getName()
method will return the correct name after(order,int...)
has been called.
-
-
Method Details
-
getCreateFormEntity
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
Set the name of the form field element.- Parameters:
elementName
- element name to be set.
-
getElementName
Get the elements name.- Returns:
- the element name
-
setDefaultValue
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
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
Sets the CSS value on the Styling tab for this form field.- Parameters:
css
- css value
-
setDescription
Set the description for the text input field- Parameters:
description
- The description text
-
setTitle
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
-