Search in sources :

Example 1 with FormComponentUpdatingBehavior

use of org.apache.wicket.markup.html.form.FormComponentUpdatingBehavior in project wicket by apache.

the class FormTester method select.

/**
 * Simulates selecting an option of a <code>FormComponent</code>. Supports
 * <code>RadioGroup</code>, <code>CheckGroup</code>, and <code>AbstractChoice</code> family
 * currently. The behavior is similar to interacting on the browser: For a single choice, such
 * as <code>Radio</code> or <code>DropDownList</code>, the selection will toggle each other. For
 * multiple choice, such as <code>Checkbox</code> or <code>ListMultipleChoice</code>, the
 * selection will accumulate.
 *
 * @param formComponentId
 *            relative path (from <code>Form</code>) to the selectable
 *            <code>FormComponent</code>
 * @param index
 *            index of the selectable option, starting from 0
 * @return This
 */
public FormTester select(final String formComponentId, int index) {
    checkClosed();
    FormComponent<?> component = (FormComponent<?>) workingForm.get(formComponentId);
    ChoiceSelector choiceSelector = choiceSelectorFactory.create(component);
    choiceSelector.doSelect(index);
    for (FormComponentUpdatingBehavior updater : component.getBehaviors(FormComponentUpdatingBehavior.class)) {
        tester.invokeListener(component, updater);
    }
    return this;
}
Also used : FormComponent(org.apache.wicket.markup.html.form.FormComponent) FormComponentUpdatingBehavior(org.apache.wicket.markup.html.form.FormComponentUpdatingBehavior)

Aggregations

FormComponent (org.apache.wicket.markup.html.form.FormComponent)1 FormComponentUpdatingBehavior (org.apache.wicket.markup.html.form.FormComponentUpdatingBehavior)1