Search in sources :

Example 11 with WMultiDropdown

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

the class WMultiDropdownTestingExample method addNoSelectionExample.

/**
 * Add example with no default selection.
 * @param readOnly if {@code true} then make the example read-only.
 */
private void addNoSelectionExample(final boolean readOnly) {
    String label = readOnly ? LABEL_RO_NO_SELECTION : LABEL_NO_SELECTION;
    WMultiDropdown dropdown = new WMultiDropdown(DATA_LIST);
    dropdown.setReadOnly(readOnly);
    layout.addField(label, dropdown);
}
Also used : WMultiDropdown(com.github.bordertech.wcomponents.WMultiDropdown)

Example 12 with WMultiDropdown

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

the class WMultiDropdownTestingExample method addAllSelectionExample.

/**
 * Add example with one default selection.
 * @param readOnly if {@code true} then make the example read-only.
 */
private void addAllSelectionExample(final boolean readOnly) {
    String label = readOnly ? LABEL_RO_ALL_SELECTED : LABEL_ALL_SELECTED;
    WMultiDropdown dropdown = new WMultiDropdown(DATA_LIST);
    dropdown.setSelected(DATA_LIST);
    dropdown.setReadOnly(readOnly);
    layout.addField(label, dropdown);
}
Also used : WMultiDropdown(com.github.bordertech.wcomponents.WMultiDropdown)

Example 13 with WMultiDropdown

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

the class WMultiDropdownRenderer_Test method testReadOnly.

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

Example 14 with WMultiDropdown

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

the class WMultiDropdownRenderer_Test method testDoPaintAllOptions.

@Test
public void testDoPaintAllOptions() throws IOException, SAXException, XpathException {
    WMultiDropdown dropdown = new WMultiDropdown(new String[] { "a", "b", "c" });
    dropdown.setDisabled(true);
    setFlag(dropdown, ComponentModel.HIDE_FLAG, true);
    dropdown.setMandatory(true);
    dropdown.setSubmitOnChange(true);
    dropdown.setToolTip("tool tip");
    dropdown.setAccessibleText("accessible text");
    dropdown.setMinSelect(1);
    dropdown.setMaxSelect(2);
    assertSchemaMatch(dropdown);
    assertXpathEvaluatesTo(dropdown.getId(), "//ui:multidropdown/@id", dropdown);
    assertXpathEvaluatesTo("true", "//ui:multidropdown/@disabled", dropdown);
    assertXpathEvaluatesTo("true", "//ui:multidropdown/@hidden", dropdown);
    assertXpathEvaluatesTo("true", "//ui:multidropdown/@required", dropdown);
    assertXpathEvaluatesTo("true", "//ui:multidropdown/@submitOnChange", dropdown);
    assertXpathEvaluatesTo("tool tip", "//ui:multidropdown/@toolTip", dropdown);
    assertXpathEvaluatesTo("accessible text", "//ui:multidropdown/@accessibleText", dropdown);
    assertXpathEvaluatesTo("1", "//ui:multidropdown/@min", dropdown);
    assertXpathEvaluatesTo("2", "//ui:multidropdown/@max", dropdown);
}
Also used : WMultiDropdown(com.github.bordertech.wcomponents.WMultiDropdown) Test(org.junit.Test)

Example 15 with WMultiDropdown

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

the class WMultiDropdownRenderer_Test method testDoPaint.

@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
    WMultiDropdown dropdown = new WMultiDropdown(new String[] { "a", "b", "c" });
    setActiveContext(createUIContext());
    assertSchemaMatch(dropdown);
    assertXpathEvaluatesTo("3", "count(//ui:multidropdown/ui:option)", dropdown);
    assertXpathNotExists("//ui:multidropdown/@rows", dropdown);
    // Check selected (default to first option)
    assertXpathEvaluatesTo("a", "normalize-space(//ui:multidropdown/ui:option[@selected='true'])", dropdown);
    setActiveContext(createUIContext());
    dropdown.setSelected(Arrays.asList(new String[] { "b" }));
    assertSchemaMatch(dropdown);
    assertXpathEvaluatesTo("3", "count(//ui:multidropdown/ui:option)", dropdown);
    assertXpathEvaluatesTo("b", "normalize-space(//ui:multidropdown/ui:option[@selected='true'])", dropdown);
    // Check max inputs
    dropdown.setMaxInputs(123);
    assertSchemaMatch(dropdown);
    assertXpathEvaluatesTo("123", "//ui:multidropdown/@max", dropdown);
}
Also used : WMultiDropdown(com.github.bordertech.wcomponents.WMultiDropdown) Test(org.junit.Test)

Aggregations

WMultiDropdown (com.github.bordertech.wcomponents.WMultiDropdown)15 Test (org.junit.Test)8 OptionGroup (com.github.bordertech.wcomponents.OptionGroup)2 WDropdown (com.github.bordertech.wcomponents.WDropdown)1 WLabel (com.github.bordertech.wcomponents.WLabel)1 WMultiSelect (com.github.bordertech.wcomponents.WMultiSelect)1 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)1