FormComponent component = (FormComponent)workingForm.get(formComponentId); ChoiceSelector choiceSelector = choiceSelectorFactory.create(component); choiceSelector.doSelect(index); if (component instanceof DropDownChoice)
FormComponent<?> component = (FormComponent<?>)workingForm.get(formComponentId); ChoiceSelector choiceSelector = choiceSelectorFactory.create(component); choiceSelector.doSelect(index); if (component instanceof DropDownChoice)
/** * 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; }
/** * 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; }