Search in sources :

Example 1 with WPasswordField

use of com.github.bordertech.wcomponents.WPasswordField 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 WPasswordField

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

the class WPasswordFieldRenderer_Test method testReadOnly.

@Test
public void testReadOnly() throws IOException, SAXException, XpathException {
    WPasswordField field = new WPasswordField();
    field.setReadOnly(true);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("true", "//ui:passwordfield/@readOnly", field);
}
Also used : WPasswordField(com.github.bordertech.wcomponents.WPasswordField) Test(org.junit.Test)

Example 3 with WPasswordField

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

the class WPasswordFieldRenderer_Test method testDoPaint.

@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
    WPasswordField field = new WPasswordField();
    WButton button = new WButton();
    WContainer root = new WContainer();
    root.add(field);
    root.add(button);
    assertSchemaMatch(field);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getId(), "//ui:passwordfield/@id", field);
    assertXpathNotExists("//ui:passwordfield/@disabled", field);
    assertXpathNotExists("//ui:passwordfield/@hidden", field);
    assertXpathNotExists("//ui:passwordfield/@required", field);
    assertXpathNotExists("//ui:passwordfield/@readOnly", field);
    assertXpathNotExists("//ui:passwordfield/@minLength", field);
    assertXpathNotExists("//ui:passwordfield/@maxLength", field);
    assertXpathNotExists("//ui:passwordfield/@toolTip", field);
    assertXpathNotExists("//ui:passwordfield/@accessibleText", field);
    assertXpathNotExists("//ui:passwordfield/@size", field);
    assertXpathNotExists("//ui:passwordfield/@buttonId", field);
    assertXpathNotExists("//ui:passwordfield/@autocomplete", field);
    field.setDisabled(true);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("true", "//ui:passwordfield/@disabled", field);
    setFlag(field, ComponentModel.HIDE_FLAG, true);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("true", "//ui:passwordfield/@hidden", field);
    field.setMandatory(true);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("true", "//ui:passwordfield/@required", field);
    field.setMinLength(45);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("45", "//ui:passwordfield/@minLength", field);
    field.setMaxLength(50);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("50", "//ui:passwordfield/@maxLength", field);
    field.setToolTip("tooltip");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getToolTip(), "//ui:passwordfield/@toolTip", field);
    field.setAccessibleText("accessible");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getAccessibleText(), "//ui:passwordfield/@accessibleText", field);
    field.setColumns(40);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("40", "//ui:passwordfield/@size", field);
    field.setDefaultSubmitButton(button);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(button.getId(), "//ui:passwordfield/@buttonId", field);
    field.setText("Hello");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("", "normalize-space(//ui:passwordfield)", field);
    field.setPlaceholder("enter stuff here");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("enter stuff here", "//ui:passwordfield/@placeholder", field);
    field.setAutocomplete(Password.CURRENT);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getAutocomplete(), "//ui:passwordfield/@autocomplete", field);
    field.setAutocompleteOff();
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(AutocompleteUtil.getOff(), "//ui:passwordfield/@autocomplete", field);
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer) WPasswordField(com.github.bordertech.wcomponents.WPasswordField) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Example 4 with WPasswordField

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

the class WPasswordFieldRenderer_Test method testRendererCorrectlyConfigured.

@Test
public void testRendererCorrectlyConfigured() {
    WPasswordField field = new WPasswordField();
    Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(field) instanceof WPasswordFieldRenderer);
}
Also used : WPasswordField(com.github.bordertech.wcomponents.WPasswordField) Test(org.junit.Test)

Example 5 with WPasswordField

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

the class WPasswordFieldRenderer_Test method testXssEscaping.

@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
    WPasswordField field = new WPasswordField();
    field.setToolTip(getMaliciousAttribute("ui:passwordfield"));
    assertSafeContent(field);
    field.setAccessibleText(getMaliciousAttribute("ui:passwordfield"));
    assertSafeContent(field);
}
Also used : WPasswordField(com.github.bordertech.wcomponents.WPasswordField) Test(org.junit.Test)

Aggregations

WPasswordField (com.github.bordertech.wcomponents.WPasswordField)6 Test (org.junit.Test)4 RadioButtonGroup (com.github.bordertech.wcomponents.RadioButtonGroup)1 WButton (com.github.bordertech.wcomponents.WButton)1 WCheckBox (com.github.bordertech.wcomponents.WCheckBox)1 WCheckBoxSelect (com.github.bordertech.wcomponents.WCheckBoxSelect)1 WComponent (com.github.bordertech.wcomponents.WComponent)1 WContainer (com.github.bordertech.wcomponents.WContainer)1 WDateField (com.github.bordertech.wcomponents.WDateField)1 WDropdown (com.github.bordertech.wcomponents.WDropdown)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 WMultiSelect (com.github.bordertech.wcomponents.WMultiSelect)1 WMultiSelectPair (com.github.bordertech.wcomponents.WMultiSelectPair)1 WNumberField (com.github.bordertech.wcomponents.WNumberField)1 WPartialDateField (com.github.bordertech.wcomponents.WPartialDateField)1 WPhoneNumberField (com.github.bordertech.wcomponents.WPhoneNumberField)1 WRadioButton (com.github.bordertech.wcomponents.WRadioButton)1