Search in sources :

Example 11 with RadioButtonGroup

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

RadioButtonGroup (com.github.bordertech.wcomponents.RadioButtonGroup)11 WRadioButton (com.github.bordertech.wcomponents.WRadioButton)9 Test (org.junit.Test)8 WLabel (com.github.bordertech.wcomponents.WLabel)3 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 AbstractWSelectList (com.github.bordertech.wcomponents.AbstractWSelectList)1 Margin (com.github.bordertech.wcomponents.Margin)1 SubordinateTarget (com.github.bordertech.wcomponents.SubordinateTarget)1 WCheckBox (com.github.bordertech.wcomponents.WCheckBox)1 WCheckBoxSelect (com.github.bordertech.wcomponents.WCheckBoxSelect)1 WContainer (com.github.bordertech.wcomponents.WContainer)1 WDropdown (com.github.bordertech.wcomponents.WDropdown)1 WEmailField (com.github.bordertech.wcomponents.WEmailField)1 WHeading (com.github.bordertech.wcomponents.WHeading)1 WImage (com.github.bordertech.wcomponents.WImage)1 WMultiSelect (com.github.bordertech.wcomponents.WMultiSelect)1