Search in sources :

Example 11 with WRadioButton

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

the class WRadioButtonRenderer_Test method testReadOnly.

@Test
public void testReadOnly() throws IOException, SAXException, XpathException {
    RadioButtonGroup group = new RadioButtonGroup();
    WRadioButton button = group.addRadioButton(1);
    button.setVisible(true);
    // Check readOnly
    assertXpathNotExists("//ui:radiobutton/@readOnly", button);
    button.setReadOnly(true);
    assertSchemaMatch(button);
    assertXpathEvaluatesTo("true", "//ui:radiobutton/@readOnly", button);
    // Check selected read-only
    assertXpathNotExists("//ui:radiobutton/@selected", button);
    button.setSelected(true);
    assertSchemaMatch(button);
    assertXpathEvaluatesTo("true", "//ui:radiobutton/@selected", button);
}
Also used : WRadioButton(com.github.bordertech.wcomponents.WRadioButton) RadioButtonGroup(com.github.bordertech.wcomponents.RadioButtonGroup) Test(org.junit.Test)

Example 12 with WRadioButton

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

the class WSubordinateControlRenderer_Test method testConditionWithRadioButtonGroupTarget.

@Test
public void testConditionWithRadioButtonGroupTarget() throws IOException, SAXException, XpathException {
    RadioButtonGroup rbg = new RadioButtonGroup();
    WRadioButton button1 = rbg.addRadioButton("B1");
    WRadioButton button2 = rbg.addRadioButton("B2");
    SubordinateTarget actionTarget = new WTextField();
    // Setup a rule with a condition using a Radio Button Group
    Rule rule = new Rule();
    rule.setCondition(new Equal(rbg, button2));
    rule.addActionOnTrue(new Show(actionTarget));
    rule.addActionOnFalse(new Hide(actionTarget));
    // Setup Subordinate
    WSubordinateControl control = new WSubordinateControl();
    control.addRule(rule);
    WContainer root = new WContainer();
    root.add(rbg);
    root.add(button1);
    root.add(button2);
    root.add(actionTarget);
    root.add(control);
    setActiveContext(createUIContext());
    rbg.setSelectedValue("B1");
    // Apply the controls
    control.applyTheControls();
    // Validate Schema
    assertSchemaMatch(root);
    // Check Condition Value is the Radio Button Value
    assertXpathEvaluatesTo(button2.getValue(), "//ui:subordinate/ui:condition/@value", root);
    // Check action target
    assertXpathEvaluatesTo("true", "//ui:textfield/@hidden", root);
}
Also used : Hide(com.github.bordertech.wcomponents.subordinate.Hide) SubordinateTarget(com.github.bordertech.wcomponents.SubordinateTarget) WContainer(com.github.bordertech.wcomponents.WContainer) WRadioButton(com.github.bordertech.wcomponents.WRadioButton) Equal(com.github.bordertech.wcomponents.subordinate.Equal) LessThanOrEqual(com.github.bordertech.wcomponents.subordinate.LessThanOrEqual) NotEqual(com.github.bordertech.wcomponents.subordinate.NotEqual) GreaterThanOrEqual(com.github.bordertech.wcomponents.subordinate.GreaterThanOrEqual) WSubordinateControl(com.github.bordertech.wcomponents.subordinate.WSubordinateControl) RadioButtonGroup(com.github.bordertech.wcomponents.RadioButtonGroup) Show(com.github.bordertech.wcomponents.subordinate.Show) Rule(com.github.bordertech.wcomponents.subordinate.Rule) WTextField(com.github.bordertech.wcomponents.WTextField) Test(org.junit.Test)

Aggregations

WRadioButton (com.github.bordertech.wcomponents.WRadioButton)12 RadioButtonGroup (com.github.bordertech.wcomponents.RadioButtonGroup)9 Test (org.junit.Test)6 WLabel (com.github.bordertech.wcomponents.WLabel)3 AbstractWSelectList (com.github.bordertech.wcomponents.AbstractWSelectList)2 WDateField (com.github.bordertech.wcomponents.WDateField)2 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)2 WFieldSet (com.github.bordertech.wcomponents.WFieldSet)2 WNumberField (com.github.bordertech.wcomponents.WNumberField)2 WTextField (com.github.bordertech.wcomponents.WTextField)2 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)2 Input (com.github.bordertech.wcomponents.Input)1 Labelable (com.github.bordertech.wcomponents.Labelable)1 Margin (com.github.bordertech.wcomponents.Margin)1 MultiInputComponent (com.github.bordertech.wcomponents.MultiInputComponent)1 SubordinateTarget (com.github.bordertech.wcomponents.SubordinateTarget)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