|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.util.tester.FormTester
public class FormTester
A helper class for testing validation and submission of FormComponent
s.
Nested Class Summary | |
---|---|
protected class |
FormTester.ChoiceSelector
A selector template for selecting selectable FormComponent s with an index of
option -- supports RadioGroup , CheckGroup , and
AbstractChoice family. |
Constructor Summary | |
---|---|
protected |
FormTester(java.lang.String path,
Form workingForm,
BaseWicketTester wicketTester,
boolean fillBlankString)
|
Method Summary | |
---|---|
Form |
getForm()
Retrieves the current Form object. |
java.lang.String |
getTextComponentValue(java.lang.String id)
Gets the value for an AbstractTextComponent with the provided id. |
void |
select(java.lang.String formComponentId,
int index)
Simulates selecting an option of a FormComponent . |
void |
selectMultiple(java.lang.String formComponentId,
int[] indexes)
A convenience method to select multiple options for the FormComponent . |
void |
setFile(java.lang.String formComponentId,
File file,
java.lang.String contentType)
Sets the File on a FileUploadField . |
void |
setValue(java.lang.String formComponentId,
java.lang.String value)
Simulates filling in a field on a Form . |
void |
submit()
Submits the Form . |
void |
submit(java.lang.String buttonComponentId)
A convenience method for submitting the Form with an alternate button. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected FormTester(java.lang.String path, Form workingForm, BaseWicketTester wicketTester, boolean fillBlankString)
path
- path to FormComponent
workingForm
- FormComponent
to be testedwicketTester
- WicketTester
that creates FormTester
fillBlankString
- specifies whether to fill child TextComponent
s with blank
String
sBaseWicketTester.newFormTester(String)
Method Detail |
---|
public Form getForm()
Form
object.
Form
public java.lang.String getTextComponentValue(java.lang.String id)
AbstractTextComponent
with the provided id.
id
- Component
id
public void select(java.lang.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
FormComponent
index
- index of the selectable option, starting from 0public void selectMultiple(java.lang.String formComponentId, int[] indexes)
FormComponent
. The
method only support multiple selectable FormComponent
s.
formComponentId
- relative path (from Form
) to the selectable
FormComponent
indexes
- index of the selectable option, starting from 0select(String, int)
public void setValue(java.lang.String formComponentId, java.lang.String value)
Form
.
formComponentId
- relative path (from Form
) to the selectable
FormComponent
or IFormSubmittingComponent
value
- the field valuepublic void setFile(java.lang.String formComponentId, File file, java.lang.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 void submit()
Form
. Note that submit
can be executed only once.
public void submit(java.lang.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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |