choiceSelector.doSelect(index); if (component instanceof DropDownChoice)
assignValueToFormComponent(formComponent, foundRadio.getValue()); assignValueToFormComponent(formComponent, foundCheck.getValue()); String idValue = selectAbstractChoice(formComponent, index); if (idValue == null) assignValueToFormComponent(formComponent, idValue);
assignValueToFormComponent(formComponent, foundRadio.getValue()); assignValueToFormComponent(formComponent, foundCheck.getValue()); String idValue = selectAbstractChoice(formComponent, index); if (idValue == null) assignValueToFormComponent(formComponent, idValue);
String idValue = selectAbstractChoice(formComponent, index); if (idValue == null)
choiceSelector.doSelect(index); if (component instanceof DropDownChoice)
/** * A convenience method to select multiple options for the <code>FormComponent</code>. The * method only support multiple selectable <code>FormComponent</code>s. * * @see #select(String, int) * * @param formComponentId * relative path (from <code>Form</code>) to the selectable * <code>FormComponent</code> * @param indexes * index of the selectable option, starting from 0 * @param replace * If true, than all previous selects are first reset, thus existing selects are * replaced. If false, than the new indexes will be added. */ public void selectMultiple(String formComponentId, int[] indexes, final boolean replace) { checkClosed(); if (replace == true) { // Reset first setValue(formComponentId, ""); } ChoiceSelector choiceSelector = choiceSelectorFactory.createForMultiple((FormComponent<?>)workingForm.get(formComponentId)); for (int index : indexes) { choiceSelector.doSelect(index); } }
choiceSelector.doSelect(index);
String idValue = selectAbstractChoice(formComponent, index); if (idValue == null)
choiceSelector.doSelect(index);
/** * 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; }
/** * A convenience method to select multiple options for the <code>FormComponent</code>. The * method only support multiple selectable <code>FormComponent</code>s. * * @see #select(String, int) * * @param formComponentId * relative path (from <code>Form</code>) to the selectable * <code>FormComponent</code> * @param indexes * index of the selectable option, starting from 0 */ public void selectMultiple(String formComponentId, int[] indexes) { checkClosed(); ChoiceSelector choiceSelector = choiceSelectorFactory.createForMultiple((FormComponent)workingForm.get(formComponentId)); for (int i = 0; i < indexes.length; i++) { choiceSelector.doSelect(indexes[i]); } }
/** * Selects a given index in a selectable <code>FormComponent</code>. * * @param index */ protected final void doSelect(final int index) { String value = getChoiceValueForIndex(index); assignValueToFormComponent(formComponent, value); }
/** * Selects a given index in a selectable <code>FormComponent</code>. * * @param index */ protected final void doSelect(final int index) { String value = getChoiceValueForIndex(index); assignValueToFormComponent(formComponent, value); }