use of com.github.bordertech.wcomponents.WSingleSelect 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);
}
use of com.github.bordertech.wcomponents.WSingleSelect in project wcomponents by BorderTech.
the class WSingleSelectRenderer_Test method testXssEscaping.
@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
OptionGroup optionGroup = new OptionGroup(getMaliciousAttribute("ui:optgroup"), Arrays.asList(new String[] { "dummy" }));
WSingleSelect single = new WSingleSelect(Arrays.asList(new Object[] { getInvalidCharSequence(), getMaliciousContent(), optionGroup }));
assertSafeContent(single);
single.setToolTip(getMaliciousAttribute("ui:listbox"));
assertSafeContent(single);
single.setAccessibleText(getMaliciousAttribute("ui:listbox"));
assertSafeContent(single);
}
use of com.github.bordertech.wcomponents.WSingleSelect in project wcomponents by BorderTech.
the class WSingleSelectRenderer_Test method testRendererCorrectlyConfigured.
@Test
public void testRendererCorrectlyConfigured() {
WSingleSelect single = new WSingleSelect(new String[] { "a", "b", "c" });
Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(single) instanceof WSingleSelectRenderer);
}
use of com.github.bordertech.wcomponents.WSingleSelect in project wcomponents by BorderTech.
the class WSingleSelectRenderer_Test method testReadOnly.
@Test
public void testReadOnly() throws IOException, SAXException, XpathException {
WSingleSelect single = new WSingleSelect(new String[] { "a", "b", "c" });
single.setSelected("b");
single.setReadOnly(true);
assertSchemaMatch(single);
assertXpathEvaluatesTo("true", "//ui:listbox/@readOnly", single);
assertXpathEvaluatesTo("1", "count(//ui:listbox/ui:option)", single);
assertXpathEvaluatesTo("b", "normalize-space(//ui:listbox/ui:option[@selected='true'])", single);
}
use of com.github.bordertech.wcomponents.WSingleSelect in project wcomponents by BorderTech.
the class WSingleSelectRenderer_Test method testDoPaint.
@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
WSingleSelect single = new WSingleSelect(new String[] { "a", "b", "c" });
assertSchemaMatch(single);
assertXpathEvaluatesTo(single.getId(), "//ui:listbox/@id", single);
assertXpathEvaluatesTo("3", "count(//ui:listbox/ui:option)", single);
assertXpathNotExists("//ui:listbox/@rows", single);
assertXpathEvaluatesTo("true", "//ui:listbox/@single", single);
// Check selected
assertXpathNotExists("//ui:listbox/ui:option[@selected='true']", single);
single.setSelected("b");
assertSchemaMatch(single);
assertXpathEvaluatesTo("3", "count(//ui:listbox/ui:option)", single);
assertXpathEvaluatesTo("b", "normalize-space(//ui:listbox/ui:option[@selected='true'])", single);
// Check rows
single.setRows(123);
assertSchemaMatch(single);
assertXpathEvaluatesTo("123", "//ui:listbox/@rows", single);
}
Aggregations