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);
}
Aggregations