java.lang.Object
org.apache.wicket.util.tester.FormTester
A helper class for testing validation and submission of
FormComponents.- Since:
- 1.2.6
- Author:
- Ingram Chen, Frank Bille (frankbille)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classA selector template for selecting selectableFormComponents with an index of option -- supportsRadioGroup,CheckGroup, andAbstractChoicefamily. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFormTester(String path, Form<?> workingForm, BaseWicketTester wicketTester, boolean fillBlankString) -
Method Summary
Modifier and TypeMethodDescriptionForm<?>getForm()Retrieves the currentFormobject.static String[]getInputValue(FormComponent<?> formComponent) Gets request parameter values for the form component that represents its current model valueGets the value for anAbstractTextComponentwith the provided id.booleanSimulates selecting an option of aFormComponent.selectMultiple(String formComponentId, int[] indexes) A convenience method to select multiple options for theFormComponent.selectMultiple(String formComponentId, int[] indexes, boolean replace) A convenience method to select multiple options for theFormComponent.setClearFeedbackMessagesBeforeSubmit(boolean clearFeedbackMessagesBeforeSubmit) Sets theFileon aFileUploadField.Simulates filling in a field on aForm.Simulates filling in a field on aForm.submit()Submits theForm.A convenience method for submitting theFormwith an alternate button.A convenience method for submitting theFormwith an alternate button.submitLink(String path, boolean pageRelative) A convenience method to submit the Form via a SubmitLink which may inside or outside of the Form.
-
Constructor Details
-
FormTester
protected FormTester(String path, Form<?> workingForm, BaseWicketTester wicketTester, boolean fillBlankString) - Parameters:
path- path toFormComponentworkingForm-FormComponentto be testedwicketTester-WicketTesterthat createsFormTesterfillBlankString- specifies whether to fill childTextComponents with blankStrings- See Also:
-
-
Method Details
-
getInputValue
Gets request parameter values for the form component that represents its current model value- Parameters:
formComponent-- Returns:
- array containing parameter values
-
getForm
Retrieves the currentFormobject.- Returns:
- the working
Form
-
getTextComponentValue
Gets the value for anAbstractTextComponentwith the provided id.- Parameters:
id-Componentid- Returns:
- the value of the text component
-
select
Simulates selecting an option of aFormComponent. SupportsRadioGroup,CheckGroup, andAbstractChoicefamily currently. The behavior is similar to interacting on the browser: For a single choice, such asRadioorDropDownList, the selection will toggle each other. For multiple choice, such asCheckboxorListMultipleChoice, the selection will accumulate.- Parameters:
formComponentId- relative path (fromForm) to the selectableFormComponentindex- index of the selectable option, starting from 0- Returns:
- This
-
selectMultiple
A convenience method to select multiple options for theFormComponent. The method only support multiple selectableFormComponents.- Parameters:
formComponentId- relative path (fromForm) to the selectableFormComponentindexes- index of the selectable option, starting from 0- Returns:
- This
- See Also:
-
selectMultiple
A convenience method to select multiple options for theFormComponent. The method only support multiple selectableFormComponents.- Parameters:
formComponentId- relative path (fromForm) to the selectableFormComponentindexes- index of the selectable option, starting from 0replace- If true, than all previous selects are first reset, thus existing selects are replaced. If false, than the new indexes will be added.- Returns:
- This
- See Also:
-
setValue
Simulates filling in a field on aForm.- Parameters:
formComponentId- relative path (fromForm) to the selectableFormComponentorIFormSubmittingComponentvalue- the field value- Returns:
- This
-
setValue
Simulates filling in a field on aForm.- Parameters:
formComponent- relative path (fromForm) to the selectableFormComponentorIFormSubmittingComponentvalue- the field value- Returns:
- This
-
setValue
- Parameters:
checkBoxId-value-- Returns:
- This
-
setFile
public FormTester setFile(String formComponentId, org.apache.wicket.util.file.File file, String contentType) Sets theFileon aFileUploadField.- Parameters:
formComponentId- relative path (fromForm) to the selectableFormComponent. TheFormComponentmust be of a typeFileUploadField.file- theFileto upload ornullfor an empty inputcontentType- the content type of the file. Must be a valid mime type.- Returns:
- This
-
submit
Submits theForm. Note thatsubmitcan be executed only once.- Returns:
- This
-
isClearFeedbackMessagesBeforeSubmit
-
setClearFeedbackMessagesBeforeSubmit
-
submit
A convenience method for submitting theFormwith an alternate button.Note that if the button is associated with a model, it's better to use the
setValuemethod instead:formTester.setValue("to:my:button", "value on the button"); formTester.submit();- Parameters:
buttonComponentId- relative path (fromForm) to the button- Returns:
- This
-
submit
A convenience method for submitting theFormwith an alternate button.Note that if the button is associated with a model, it's better to use the
setValuemethod instead:formTester.setValue(myButton, "value on the button"); formTester.submit();
- Parameters:
buttonComponent- relative path (fromForm) to the button- Returns:
- This
-
submitLink
A convenience method to submit the Form via a SubmitLink which may inside or outside of the Form.- Parameters:
path- The path to the SubmitLinkpageRelative- if true, than the 'path' to the SubmitLink is relative to the page. Thus the link can be outside the form. If false, the path is relative to the form and thus the link is inside the form.- Returns:
- This
-