use of com.github.bordertech.wcomponents.WEmailField 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.WEmailField in project wcomponents by BorderTech.
the class WEmailFieldRenderer_Test method testAutocomplete.
@Test
public void testAutocomplete() throws IOException, SAXException, XpathException {
WEmailField field = new WEmailField();
field.setAutocomplete(Email.EMAIL);
assertSchemaMatch(field);
assertXpathEvaluatesTo(Email.EMAIL.getValue(), "//ui:emailfield/@autocomplete", field);
}
use of com.github.bordertech.wcomponents.WEmailField in project wcomponents by BorderTech.
the class WEmailFieldRenderer_Test method testRendererCorrectlyConfigured.
@Test
public void testRendererCorrectlyConfigured() {
WEmailField textField = new WEmailField();
Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(textField) instanceof WEmailFieldRenderer);
}
use of com.github.bordertech.wcomponents.WEmailField in project wcomponents by BorderTech.
the class WEmailFieldRenderer_Test method testXssEscaping.
@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
WEmailField field = new WEmailField();
field.setText(getMaliciousContent());
assertSafeContent(field);
field.setToolTip(getMaliciousAttribute("ui:emailfield"));
assertSafeContent(field);
field.setAccessibleText(getMaliciousAttribute("ui:emailfield"));
assertSafeContent(field);
}
use of com.github.bordertech.wcomponents.WEmailField in project wcomponents by BorderTech.
the class WEmailFieldRenderer_Test method testDoPaint.
@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
WEmailField field = new WEmailField();
WButton button = new WButton();
WSuggestions suggestions = new WSuggestions();
WContainer root = new WContainer();
root.add(field);
root.add(button);
root.add(suggestions);
assertSchemaMatch(field);
assertXpathEvaluatesTo(field.getId(), "//ui:emailfield/@id", field);
assertXpathNotExists("//ui:emailfield/@disabled", field);
assertXpathNotExists("//ui:emailfield/@hidden", field);
assertXpathNotExists("//ui:emailfield/@required", field);
assertXpathNotExists("//ui:emailfield/@readOnly", field);
assertXpathNotExists("//ui:emailfield/@maxLength", field);
assertXpathNotExists("//ui:emailfield/@toolTip", field);
assertXpathNotExists("//ui:emailfield/@accessibleText", field);
assertXpathNotExists("//ui:emailfield/@size", field);
assertXpathNotExists("//ui:emailfield/@buttonId", field);
assertXpathNotExists("//ui:emailfield/@list", field);
assertXpathNotExists("//ui:emailfield/@autocomplete", field);
field.setDisabled(true);
assertSchemaMatch(field);
assertXpathEvaluatesTo("true", "//ui:emailfield/@disabled", field);
setFlag(field, ComponentModel.HIDE_FLAG, true);
assertSchemaMatch(field);
assertXpathEvaluatesTo("true", "//ui:emailfield/@hidden", field);
field.setMandatory(true);
assertSchemaMatch(field);
assertXpathEvaluatesTo("true", "//ui:emailfield/@required", field);
field.setMaxLength(50);
assertSchemaMatch(field);
assertXpathEvaluatesTo("50", "//ui:emailfield/@maxLength", field);
field.setToolTip("tooltip");
assertSchemaMatch(field);
assertXpathEvaluatesTo(field.getToolTip(), "//ui:emailfield/@toolTip", field);
field.setAccessibleText("accessible");
assertSchemaMatch(field);
assertXpathEvaluatesTo(field.getAccessibleText(), "//ui:emailfield/@accessibleText", field);
field.setColumns(40);
assertSchemaMatch(field);
assertXpathEvaluatesTo("40", "//ui:emailfield/@size", field);
field.setDefaultSubmitButton(button);
assertSchemaMatch(field);
assertXpathEvaluatesTo(button.getId(), "//ui:emailfield/@buttonId", field);
// RFC 2606
field.setText("nobody@wc.test");
assertSchemaMatch(field);
assertXpathEvaluatesTo(field.getText(), "normalize-space(//ui:emailfield)", field);
field.setSuggestions(suggestions);
assertSchemaMatch(field);
assertXpathEvaluatesTo(suggestions.getId(), "//ui:emailfield/@list", field);
field.setPlaceholder("enter stuff here");
assertSchemaMatch(field);
assertXpathEvaluatesTo("enter stuff here", "//ui:emailfield/@placeholder", field);
}
Aggregations