Search in sources :

Example 1 with WMultiSelect

use of com.github.bordertech.wcomponents.WMultiSelect in project wcomponents by BorderTech.

the class SubordinateControlOptionsExample method setupTrigger.

/**
 * Setup the trigger for the subordinate control.
 */
private void setupTrigger() {
    String label = drpTriggerType.getSelected() + " Trigger";
    WFieldLayout layout = new WFieldLayout();
    layout.setLabelWidth(LABEL_WIDTH);
    buildControlPanel.add(layout);
    switch((TriggerType) drpTriggerType.getSelected()) {
        case RadioButtonGroup:
            trigger = new RadioButtonGroup();
            WFieldSet rbSet = new WFieldSet("Select an option");
            RadioButtonGroup group = (RadioButtonGroup) trigger;
            WRadioButton rb1 = group.addRadioButton("A");
            WRadioButton rb2 = group.addRadioButton("B");
            WRadioButton rb3 = group.addRadioButton("C");
            rbSet.add(group);
            rbSet.add(rb1);
            rbSet.add(new WLabel("A", rb1));
            rbSet.add(new WText("\u00a0"));
            rbSet.add(rb2);
            rbSet.add(new WLabel("B", rb2));
            rbSet.add(new WText("\u00a0"));
            rbSet.add(rb3);
            rbSet.add(new WLabel("C", rb3));
            layout.addField(label, rbSet);
            return;
        case CheckBox:
            trigger = new WCheckBox();
            break;
        case CheckBoxSelect:
            trigger = new WCheckBoxSelect(LOOKUP_TABLE_NAME);
            break;
        case DateField:
            trigger = new WDateField();
            break;
        case Dropdown:
            trigger = new WDropdown(new TableWithNullOption(LOOKUP_TABLE_NAME));
            break;
        case EmailField:
            trigger = new WEmailField();
            break;
        case MultiSelect:
            trigger = new WMultiSelect(LOOKUP_TABLE_NAME);
            break;
        case MultiSelectPair:
            trigger = new WMultiSelectPair(LOOKUP_TABLE_NAME);
            break;
        case NumberField:
            trigger = new WNumberField();
            break;
        case PartialDateField:
            trigger = new WPartialDateField();
            break;
        case PasswordField:
            trigger = new WPasswordField();
            break;
        case PhoneNumberField:
            trigger = new WPhoneNumberField();
            break;
        case RadioButtonSelect:
            trigger = new WRadioButtonSelect(LOOKUP_TABLE_NAME);
            break;
        case SingleSelect:
            trigger = new WSingleSelect(LOOKUP_TABLE_NAME);
            break;
        case TextArea:
            trigger = new WTextArea();
            ((WTextArea) trigger).setMaxLength(1000);
            break;
        case TextField:
            trigger = new WTextField();
            break;
        default:
            throw new SystemException("Trigger type not valid");
    }
    layout.addField(label, trigger);
}
Also used : WFieldSet(com.github.bordertech.wcomponents.WFieldSet) WNumberField(com.github.bordertech.wcomponents.WNumberField) WEmailField(com.github.bordertech.wcomponents.WEmailField) WPasswordField(com.github.bordertech.wcomponents.WPasswordField) WMultiSelect(com.github.bordertech.wcomponents.WMultiSelect) WLabel(com.github.bordertech.wcomponents.WLabel) WTextArea(com.github.bordertech.wcomponents.WTextArea) WRadioButton(com.github.bordertech.wcomponents.WRadioButton) WDropdown(com.github.bordertech.wcomponents.WDropdown) SystemException(com.github.bordertech.wcomponents.util.SystemException) WText(com.github.bordertech.wcomponents.WText) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) TableWithNullOption(com.github.bordertech.wcomponents.examples.common.ExampleLookupTable.TableWithNullOption) WRadioButtonSelect(com.github.bordertech.wcomponents.WRadioButtonSelect) WTextField(com.github.bordertech.wcomponents.WTextField) WCheckBoxSelect(com.github.bordertech.wcomponents.WCheckBoxSelect) WMultiSelectPair(com.github.bordertech.wcomponents.WMultiSelectPair) WPhoneNumberField(com.github.bordertech.wcomponents.WPhoneNumberField) WSingleSelect(com.github.bordertech.wcomponents.WSingleSelect) RadioButtonGroup(com.github.bordertech.wcomponents.RadioButtonGroup) WCheckBox(com.github.bordertech.wcomponents.WCheckBox) WPartialDateField(com.github.bordertech.wcomponents.WPartialDateField) WDateField(com.github.bordertech.wcomponents.WDateField)

Example 2 with WMultiSelect

use of com.github.bordertech.wcomponents.WMultiSelect in project wcomponents by BorderTech.

the class LoadAjaxControlsExample method createFields.

/**
 * @param layout the layout to add the fields to
 * @param table the lookupTable to use on the fields
 */
private void createFields(final WFieldLayout layout, final Object table) {
    WDropdown down = new WDropdown(table);
    down.setType(DropdownType.COMBO);
    layout.addField("Combo Dropdown", down);
    WMultiDropdown multi = new WMultiDropdown(table);
    layout.addField("Multi Dropdown", multi);
    WMultiSelect select = new WMultiSelect(table);
    layout.addField("Multi Select", select);
}
Also used : WDropdown(com.github.bordertech.wcomponents.WDropdown) WMultiDropdown(com.github.bordertech.wcomponents.WMultiDropdown) WMultiSelect(com.github.bordertech.wcomponents.WMultiSelect)

Example 3 with WMultiSelect

use of com.github.bordertech.wcomponents.WMultiSelect in project wcomponents by BorderTech.

the class WMultiSelectRenderer_Test method testDoPaintOptions.

@Test
public void testDoPaintOptions() throws IOException, SAXException, XpathException {
    String tooltip = "test tooltip";
    String accessible = "test accessible text";
    int rows = 2;
    WMultiSelect multi = new WMultiSelect(new String[] { "a", "b", "c" });
    multi.setDisabled(true);
    setFlag(multi, ComponentModel.HIDE_FLAG, true);
    multi.setMandatory(true);
    multi.setSubmitOnChange(true);
    multi.setToolTip(tooltip);
    multi.setAccessibleText(accessible);
    multi.setRows(rows);
    multi.setMinSelect(1);
    multi.setMaxSelect(2);
    assertSchemaMatch(multi);
    assertXpathEvaluatesTo(multi.getId(), "//ui:listbox/@id", multi);
    assertXpathEvaluatesTo("true", "//ui:listbox/@disabled", multi);
    assertXpathEvaluatesTo("true", "//ui:listbox/@hidden", multi);
    assertXpathEvaluatesTo("true", "//ui:listbox/@required", multi);
    assertXpathEvaluatesTo("true", "//ui:listbox/@submitOnChange", multi);
    assertXpathEvaluatesTo(tooltip, "//ui:listbox/@toolTip", multi);
    assertXpathEvaluatesTo(accessible, "//ui:listbox/@accessibleText", multi);
    assertXpathEvaluatesTo(Integer.toString(rows), "//ui:listbox/@rows", multi);
    assertXpathEvaluatesTo("", "//ui:listbox/@single", multi);
    assertXpathEvaluatesTo("1", "//ui:listbox/@min", multi);
    assertXpathEvaluatesTo("2", "//ui:listbox/@max", multi);
}
Also used : WMultiSelect(com.github.bordertech.wcomponents.WMultiSelect) Test(org.junit.Test)

Example 4 with WMultiSelect

use of com.github.bordertech.wcomponents.WMultiSelect in project wcomponents by BorderTech.

the class WMultiSelectRenderer_Test method testReadOnly.

@Test
public void testReadOnly() throws IOException, SAXException, XpathException {
    WMultiSelect multi = new WMultiSelect(new String[] { "a", "b", "c" });
    setActiveContext(createUIContext());
    multi.setSelected(Arrays.asList(new String[] { "b" }));
    // Check Readonly - only render selected option
    multi.setReadOnly(true);
    assertSchemaMatch(multi);
    assertXpathEvaluatesTo("true", "//ui:listbox/@readOnly", multi);
    assertXpathEvaluatesTo("1", "count(//ui:listbox/ui:option)", multi);
    assertXpathEvaluatesTo("b", "normalize-space(//ui:listbox/ui:option[@selected='true'])", multi);
}
Also used : WMultiSelect(com.github.bordertech.wcomponents.WMultiSelect) Test(org.junit.Test)

Example 5 with WMultiSelect

use of com.github.bordertech.wcomponents.WMultiSelect in project wcomponents by BorderTech.

the class WMultiSelectRenderer_Test method testRendererCorrectlyConfigured.

@Test
public void testRendererCorrectlyConfigured() {
    WMultiSelect multi = new WMultiSelect(new String[] { "a", "b", "c" });
    Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(multi) instanceof WMultiSelectRenderer);
}
Also used : WMultiSelect(com.github.bordertech.wcomponents.WMultiSelect) Test(org.junit.Test)

Aggregations

WMultiSelect (com.github.bordertech.wcomponents.WMultiSelect)14 Test (org.junit.Test)11 WDropdown (com.github.bordertech.wcomponents.WDropdown)6 WTextArea (com.github.bordertech.wcomponents.WTextArea)5 WTextField (com.github.bordertech.wcomponents.WTextField)5 OptionGroup (com.github.bordertech.wcomponents.OptionGroup)3 RadioButtonGroup (com.github.bordertech.wcomponents.RadioButtonGroup)1 WCheckBox (com.github.bordertech.wcomponents.WCheckBox)1 WCheckBoxSelect (com.github.bordertech.wcomponents.WCheckBoxSelect)1 WDateField (com.github.bordertech.wcomponents.WDateField)1 WEmailField (com.github.bordertech.wcomponents.WEmailField)1 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)1 WFieldSet (com.github.bordertech.wcomponents.WFieldSet)1 WLabel (com.github.bordertech.wcomponents.WLabel)1 WMultiDropdown (com.github.bordertech.wcomponents.WMultiDropdown)1 WMultiSelectPair (com.github.bordertech.wcomponents.WMultiSelectPair)1 WNumberField (com.github.bordertech.wcomponents.WNumberField)1 WPartialDateField (com.github.bordertech.wcomponents.WPartialDateField)1 WPasswordField (com.github.bordertech.wcomponents.WPasswordField)1 WPhoneNumberField (com.github.bordertech.wcomponents.WPhoneNumberField)1