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