public class Start extends AbstractComponent
Modifier and Type | Field and Description |
---|---|
static Charset |
CHARSET_UTF8 |
static String |
OPT_ACTION_TYPE_STORE |
static String |
PROP_ACTION_STORE_CONTENT_PATH |
static String |
PROP_ACTION_TYPE |
static String |
PROP_CLIENT_VALIDATION |
static String |
PROP_FORM_ID |
static String |
PROP_REDIRECT |
static String |
PROP_VALIDATION_RT |
static String |
PROP_WORKFLOW |
static String |
RESOURCE_TYPE |
changeProperties, client, componentPath, DEFAULT_LOCATION, jsonNode, location, pagePath
Constructor and Description |
---|
Start(ComponentClient client,
String pagePath,
String location,
String nameHint)
The constructor stores all the component path information like parentPage, name etc.
|
Modifier and Type | Method and Description |
---|---|
org.apache.sling.testing.clients.SlingHttpResponse |
create(String order,
int... expectedStatus)
We override the default create call, so we can capture the reference to the end component.
|
org.apache.http.HttpEntity |
createMultipartEntity()
Create a MultiPartEntity out of the all the values of the Form components
which are between this Start component and its End component in the page paragraph list.
|
org.apache.sling.testing.clients.util.FormEntityBuilder |
getCreateFormEntity(String order)
Returns the FormEntityBuilder used for the create request in
AbstractComponent.create(String,int...) . |
String |
getFormActionStore()
Get the action property value (which is the action store content path) from this start component.
|
End |
getFormEndComponent()
Returns the end form component that belongs to this start component.
|
String |
getFormId()
Convenience method that returns the form id
|
String |
getFormValue(String componentName)
returns the string value set for this form element
|
String |
getResourceType()
The resource type for the component, e.g.
|
void |
setActionType(String actionTypeHandle)
Defines what type of action should be executed upon form submission.
|
void |
setClientValidation(boolean validate)
Defines if the form should get validated client side before submission
|
void |
setClientValidationResourceType(String resourceType)
Defines a form validation resource type if you want to validate the entire form (instead of individual fields).
|
void |
setFormActionStore(String contentPath)
Sets action type to 'Store Content', and sets the 'Action' path where the
data will get stored.
|
void |
setFormId(String formId)
Sets the form id
|
void |
setFormValueToSubmit(String componentName,
Object value)
The value we want to submit for a form field.
|
void |
setRedirect(String pageHandle)
Sets the handle for the redirect after form submit.
|
void |
setWorkflowModel(String modelHandle)
Set workflow model that should be started on form submission.
|
void |
submit()
this method will 'emulate' the submit of this form by rebuilding the
multipart/form-data request, collecting all the values from the form fields
found between the start and end component
|
org.apache.sling.testing.clients.SlingHttpResponse |
submit2()
this method will 'emulate' the submit of this form by rebuilding the
multipart/form-data request, collecting all the values from the form fields
found between the start and end component
|
getClient, getComponentNode, getComponentPath, getFirstChild, getLocation, getName, getNext, getNextNodePath, getPagePath, getParentPath, getPrevious, getPreviousNodePath, getProperty, getPropertyAsString, getPropertyAsStringArray, reorder, save, setProperty, setProperty
public static final String RESOURCE_TYPE
public static final String PROP_REDIRECT
public static final String PROP_WORKFLOW
public static final String PROP_ACTION_TYPE
public static final String PROP_FORM_ID
public static final String PROP_CLIENT_VALIDATION
public static final String PROP_VALIDATION_RT
public static final String OPT_ACTION_TYPE_STORE
public static final String PROP_ACTION_STORE_CONTENT_PATH
public static final Charset CHARSET_UTF8
public Start(ComponentClient client, String pagePath, String location, String nameHint)
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.public String getResourceType()
AbstractComponent
sling:resourceType
property of the node.getResourceType
in class AbstractComponent
public org.apache.sling.testing.clients.util.FormEntityBuilder getCreateFormEntity(String order)
AbstractComponent
AbstractComponent.create(String,int...)
. This method can be
overridden in a subclass to extend the parameters that need to sent with the creation request.getCreateFormEntity
in class AbstractComponent
order
- Defines where the component should be added in relation to its siblings. Possible values
are first
, last
, before [nodeName]
, after [nodeName]
._charset_
,./sling:resourceType
and
:nameHint
set.public org.apache.sling.testing.clients.SlingHttpResponse create(String order, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException
create
in class AbstractComponent
order
- Defines where the component should be added in relation to its siblings. Possible values
are first
, last
, before [nodeName]
, after [nodeName]
.expectedStatus
- list of expected HTTP Status to be returned, if not set, 201 is assumed.org.apache.sling.testing.clients.ClientException
- if the request failsInterruptedException
- to mark this method as waitingpublic End getFormEndComponent()
public void setRedirect(String pageHandle)
pageHandle
- handle to redirect pagepublic void setWorkflowModel(String modelHandle)
modelHandle
- handle of of the workflow modelpublic void setActionType(String actionTypeHandle)
actionTypeHandle
- handle to the action componentpublic void setFormId(String formId)
formId
- name for the form idpublic String getFormId()
public void setClientValidation(boolean validate)
validate
- set true if client validation of form should occur.public void setClientValidationResourceType(String resourceType)
resourceType
- the validation resource typepublic void setFormActionStore(String contentPath)
contentPath
- path where the data will be storedpublic String getFormActionStore() throws org.apache.sling.testing.clients.ClientException, InterruptedException
org.apache.sling.testing.clients.ClientException
- if the request failsInterruptedException
- to mark this method as waitingpublic void submit() throws org.apache.sling.testing.clients.ClientException, InterruptedException
org.apache.sling.testing.clients.ClientException
- if the request failsInterruptedException
- to mark this method as waitingpublic org.apache.sling.testing.clients.SlingHttpResponse submit2() throws org.apache.sling.testing.clients.ClientException, InterruptedException
org.apache.sling.testing.clients.ClientException
- if the request failsInterruptedException
- to mark this method as waitingpublic org.apache.http.HttpEntity createMultipartEntity() throws org.apache.sling.testing.clients.ClientException, InterruptedException
org.apache.sling.testing.clients.ClientException
- if the request failsInterruptedException
- to mark this method as waitingpublic void setFormValueToSubmit(String componentName, Object value)
submit()
gets called and is located between the form start and
end component.
If the the value is not set or set to null at the time of submitting
then the form field is not added at all.
If set to an empty String, it will submitted as such.componentName
- the name of the form field component, associated with this valuevalue
- the value send upon submit of the formpublic String getFormValue(String componentName) throws org.apache.sling.testing.clients.ClientException
componentName
- component nameorg.apache.sling.testing.clients.ClientException
- if the request failsCopyright © 2018. All rights reserved.