wicket.util.tester
Class FormTester

java.lang.Object
  extended by wicket.util.tester.FormTester

public class FormTester
extends java.lang.Object

A helper for testing validaiton and submission of Form component.

Author:
Ingram Chen

Nested Class Summary
protected  class FormTester.ChoiceSelector
          A selector template for selecting seletable form component via index of option, support RadioGroup, CheckGroup, and AbstractChoice family.
 
Constructor Summary
protected FormTester(java.lang.String path, Form workingForm, WicketTester wicketTester, boolean fillBlankString)
           
 
Method Summary
 void select(java.lang.String formComponentId, int index)
          simulate selecting an option of a Form Component.
 void selectMultiple(java.lang.String formComponentId, int[] indexes)
          A convenient method to select multiple options for the form component.
 void setValue(java.lang.String formComponentId, java.lang.String value)
          simulate filling a field of a Form.
 void submit()
          submit the form.
 void submit(java.lang.String buttonComponentId)
          A convenient method to submit form with alternative button.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormTester

protected FormTester(java.lang.String path,
                     Form workingForm,
                     WicketTester wicketTester,
                     boolean fillBlankString)
Parameters:
path - path to form component
workingForm - form component to be test
wicketTester - wicketTester that create FormTester
fillBlankString - specify whether filling child Text Components with blank String
See Also:
WicketTester.newFormTester(String)
Method Detail

setValue

public void setValue(java.lang.String formComponentId,
                     java.lang.String value)
simulate filling a field of a Form.

Parameters:
formComponentId - relative path (from form) to formComponent
value - field value of form.

submit

public void submit()
submit the form. note that submit() can be executed only once.


submit

public void submit(java.lang.String buttonComponentId)
A convenient method to submit form with alternative button. Note that if the button associates with a model, it's better to use setValue() instead:
 formTester.setValue("to:my:button", "value on the button");
 formTester.submit();
 

Parameters:
buttonComponentId - relative path (from form) to the button

select

public void select(java.lang.String formComponentId,
                   int index)
simulate selecting an option of a Form Component. Support RadioGroup, CheckGroup, and AbstractChoice family currently. The behavior is similar to interacting on the browser: For single choice, such as Radio or DropDownList, the selection will toggle each other. For multiple choice, such as Checkbox or ListMultipleChoice, the selection will cumulate.

Parameters:
formComponentId - relative path (from form) to selectable formComponent
index - index of selectable option, start from 0

selectMultiple

public void selectMultiple(java.lang.String formComponentId,
                           int[] indexes)
A convenient method to select multiple options for the form component. The method only support multiple selectable form component.

Parameters:
formComponentId - relative path (from form) to selectable formComponent
indexes - index of selectable option, start from 0
See Also:
select(String, int)


Copyright © 2004-2007 Wicket developers. All Rights Reserved.