use of com.github.bordertech.wcomponents.WRadioButtonSelect in project wcomponents by BorderTech.
the class WRadioButtonSelectRenderer_Test method testOptGroupException.
@Test(expected = SystemException.class)
public void testOptGroupException() throws IOException, SAXException, XpathException {
OptionGroup optionGroup = new OptionGroup("Test", Arrays.asList(new String[] { "A", "B" }));
WRadioButtonSelect group = new WRadioButtonSelect(Arrays.asList(new Object[] { "X", optionGroup }));
assertSchemaMatch(group);
}
use of com.github.bordertech.wcomponents.WRadioButtonSelect in project wcomponents by BorderTech.
the class WRadioButtonSelectRenderer_Test method testDoPaintAllOptions.
@Test
public void testDoPaintAllOptions() throws IOException, SAXException, XpathException {
WRadioButtonSelect group = new WRadioButtonSelect();
// Set ALL Options
group.setDisabled(true);
setFlag(group, ComponentModel.HIDE_FLAG, true);
group.setMandatory(true);
group.setSubmitOnChange(true);
group.setToolTip("tip");
group.setFrameless(true);
group.setAjaxTarget(new WPanel());
group.setButtonLayout(WRadioButtonSelect.LAYOUT_COLUMNS);
group.setButtonColumns(2);
// Validate ALL Options
assertSchemaMatch(group);
assertXpathEvaluatesTo(group.getId(), "//ui:radiobuttonselect/@id", group);
assertXpathEvaluatesTo("true", "//ui:radiobuttonselect/@disabled", group);
assertXpathEvaluatesTo("true", "//ui:radiobuttonselect/@hidden", group);
assertXpathEvaluatesTo("true", "//ui:radiobuttonselect/@required", group);
assertXpathEvaluatesTo("true", "//ui:radiobuttonselect/@submitOnChange", group);
assertXpathEvaluatesTo("tip", "//ui:radiobuttonselect/@toolTip", group);
assertXpathEvaluatesTo("true", "//ui:radiobuttonselect/@frameless", group);
assertXpathEvaluatesTo("column", "//ui:radiobuttonselect/@layout", group);
assertXpathEvaluatesTo("2", "//ui:radiobuttonselect/@layoutColumnCount", group);
assertXpathEvaluatesTo(group.getId(), "//ui:ajaxtrigger/@triggerId", group);
}
use of com.github.bordertech.wcomponents.WRadioButtonSelect in project wcomponents by BorderTech.
the class SubordinateControlMandatoryExample method build.
/**
* Creates the component to be added to the validation container. This is doen in a static method because the
* component is passed into the superclass constructor.
*
* @return the component to be added to the validation container.
*/
private static WComponent build() {
WContainer root = new WContainer();
WSubordinateControl control = new WSubordinateControl();
root.add(control);
WFieldLayout layout = new WFieldLayout();
layout.setLabelWidth(25);
layout.setMargin(new com.github.bordertech.wcomponents.Margin(0, 0, 12, 0));
WCheckBox checkBox = new WCheckBox();
layout.addField("Set Mandatory", checkBox);
WTextField text = new WTextField();
layout.addField("Might need this field", text);
WTextField mandatoryField = new WTextField();
layout.addField("Another field always mandatory", mandatoryField);
mandatoryField.setMandatory(true);
final WRadioButtonSelect rbSelect = new WRadioButtonSelect("australian_state");
layout.addField("Select a state", rbSelect);
root.add(layout);
Rule rule = new Rule();
rule.setCondition(new Equal(checkBox, Boolean.TRUE.toString()));
rule.addActionOnTrue(new Mandatory(text));
rule.addActionOnFalse(new Optional(text));
rule.addActionOnTrue(new Mandatory(rbSelect));
rule.addActionOnFalse(new Optional(rbSelect));
control.addRule(rule);
return root;
}
use of com.github.bordertech.wcomponents.WRadioButtonSelect in project wcomponents by BorderTech.
the class WRadioButtonSelectExample method makeSimpleExample.
/**
* Make a simple editable example. The label for this example is used to get the example for use in the unit tests.
*/
private void makeSimpleExample() {
add(new WHeading(HeadingLevel.H3, "Simple WRadioButtonSelect"));
WPanel examplePanel = new WPanel();
examplePanel.setLayout(new FlowLayout(FlowLayout.VERTICAL, Size.MEDIUM));
add(examplePanel);
/**
* The radio button select.
*/
final WRadioButtonSelect rbSelect = new WRadioButtonSelect("australian_state");
final WTextField text = new WTextField();
text.setReadOnly(true);
text.setText(NO_SELECTION);
WButton update = new WButton("Update");
update.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
text.setText("The selected item is: " + rbSelect.getSelected());
}
});
// setting the default submit button improves usability. It can be set on a WPanel or the WRadioButtonSelect directly
examplePanel.setDefaultSubmitButton(update);
examplePanel.add(new WLabel("Select a state or territory", rbSelect));
examplePanel.add(rbSelect);
examplePanel.add(text);
examplePanel.add(update);
add(new WAjaxControl(update, text));
}
use of com.github.bordertech.wcomponents.WRadioButtonSelect in project wcomponents by BorderTech.
the class WRadioButtonSelectExample method addMandatorySelectExample.
/**
* adds a WRadioButtonSelect with setMandatory(true).
*/
private void addMandatorySelectExample() {
add(new WHeading(HeadingLevel.H3, "Mandatory WRadioButtonSelect"));
add(new ExplanatoryText("When a WRadioButtonSelect is mandatory it needs a visible labelling element, otherwise many users may not know that " + "the component requires an answer."));
final WRadioButtonSelect select = new WRadioButtonSelect("australian_state");
select.setButtonLayout(WRadioButtonSelect.LAYOUT_FLAT);
select.setMandatory(true);
add(new WLabel("Mandatory selection", select));
add(select);
add(new WHeading(HeadingLevel.H3, "Mandatory WRadioButtonSelect in a WFieldLayout"));
WRadioButtonSelect select2 = new WRadioButtonSelect("australian_state");
select2.setButtonLayout(WRadioButtonSelect.LAYOUT_FLAT);
select2.setMandatory(true);
final WFieldLayout layout = new WFieldLayout();
layout.setLabelWidth(25);
add(layout);
layout.addField("Required selection", select2).getLabel().setHint("Required");
select2 = new WRadioButtonSelect("australian_state");
select2.setButtonLayout(WRadioButtonSelect.LAYOUT_FLAT);
select2.setMandatory(true);
select2.setToolTip("Select a state");
layout.addField((WLabel) null, select2);
}
Aggregations