|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.wicket.util.tester.FormTester
public class FormTester
A helper class for testing validation and submission of FormComponents.
| Nested Class Summary | |
|---|---|
protected class |
FormTester.ChoiceSelector
A selector template for selecting selectable FormComponents with an index of
option -- supports RadioGroup, CheckGroup, and
AbstractChoice family. |
| Constructor Summary | |
|---|---|
protected |
FormTester(String path,
Form<?> workingForm,
BaseWicketTester wicketTester,
boolean fillBlankString)
|
| Method Summary | |
|---|---|
Form<?> |
getForm()
Retrieves the current Form object. |
static String[] |
getInputValue(FormComponent<?> formComponent)
Gets request parameter values for the form component that represents its current model value |
String |
getTextComponentValue(String id)
Gets the value for an AbstractTextComponent with the provided id. |
FormTester |
select(String formComponentId,
int index)
Simulates selecting an option of a FormComponent. |
FormTester |
selectMultiple(String formComponentId,
int[] indexes)
A convenience method to select multiple options for the FormComponent. |
FormTester |
selectMultiple(String formComponentId,
int[] indexes,
boolean replace)
A convenience method to select multiple options for the FormComponent. |
FormTester |
setFile(String formComponentId,
File file,
String contentType)
Sets the File on a FileUploadField. |
FormTester |
setValue(Component formComponent,
String value)
Simulates filling in a field on a Form. |
FormTester |
setValue(String checkBoxId,
boolean value)
|
FormTester |
setValue(String formComponentId,
String value)
Simulates filling in a field on a Form. |
FormTester |
submit()
Submits the Form. |
FormTester |
submit(Component buttonComponent)
A convenience method for submitting the Form with an alternate button. |
FormTester |
submit(String buttonComponentId)
A convenience method for submitting the Form with an alternate button. |
FormTester |
submitLink(String path,
boolean pageRelative)
A convenience method to submit the Form via a SubmitLink which may inside or outside of the Form. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected FormTester(String path,
Form<?> workingForm,
BaseWicketTester wicketTester,
boolean fillBlankString)
path - path to FormComponentworkingForm - FormComponent to be testedwicketTester - WicketTester that creates FormTesterfillBlankString - specifies whether to fill child TextComponents with blank
StringsBaseWicketTester.newFormTester(String)| Method Detail |
|---|
public static String[] getInputValue(FormComponent<?> formComponent)
formComponent -
public Form<?> getForm()
Form object.
Formpublic String getTextComponentValue(String id)
AbstractTextComponent with the provided id.
id - Component id
public FormTester select(String formComponentId,
int index)
FormComponent. Supports
RadioGroup, CheckGroup, and AbstractChoice family
currently. The behavior is similar to interacting on the browser: For a single choice, such
as Radio or DropDownList, the selection will toggle each other. For
multiple choice, such as Checkbox or ListMultipleChoice, the
selection will accumulate.
formComponentId - relative path (from Form) to the selectable
FormComponentindex - index of the selectable option, starting from 0
public FormTester selectMultiple(String formComponentId,
int[] indexes)
FormComponent. The
method only support multiple selectable FormComponents.
formComponentId - relative path (from Form) to the selectable
FormComponentindexes - index of the selectable option, starting from 0
select(String, int)
public FormTester selectMultiple(String formComponentId,
int[] indexes,
boolean replace)
FormComponent. The
method only support multiple selectable FormComponents.
formComponentId - relative path (from Form) to the selectable
FormComponentindexes - 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.
select(String, int)
public FormTester setValue(String formComponentId,
String value)
Form.
formComponentId - relative path (from Form) to the selectable
FormComponent or IFormSubmittingComponentvalue - the field value
public FormTester setValue(Component formComponent,
String value)
Form.
formComponent - relative path (from Form) to the selectable
FormComponent or IFormSubmittingComponentvalue - the field value
public FormTester setValue(String checkBoxId,
boolean value)
checkBoxId - value -
public FormTester setFile(String formComponentId,
File file,
String contentType)
File on a FileUploadField.
formComponentId - relative path (from Form) to the selectable
FormComponent. The FormComponent must be of a type
FileUploadField.file - the File to upload.contentType - the content type of the file. Must be a valid mime type.
public FormTester submit()
Form. Note that submit can be executed only once.
public FormTester submit(String buttonComponentId)
Form with an alternate button.
Note that if the button is associated with a model, it's better to use the
setValue method instead:
formTester.setValue("to:my:button", "value on the button");
formTester.submit();
buttonComponentId - relative path (from Form) to the button
public FormTester submit(Component buttonComponent)
Form with an alternate button.
Note that if the button is associated with a model, it's better to use the
setValue method instead:
formTester.setValue(myButton, "value on the button"); formTester.submit();
buttonComponent - relative path (from Form) to the button
public FormTester submitLink(String path,
boolean pageRelative)
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.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||