use of com.github.bordertech.wcomponents.WContainer in project wcomponents by BorderTech.
the class SubordinateControlExample method build.
/**
* @return a new instance of the example UI.
*/
private static WComponent build() {
WContainer panel = new WContainer();
panel.add(new CardSelector());
return panel;
}
use of com.github.bordertech.wcomponents.WContainer 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.WContainer in project wcomponents by BorderTech.
the class WCheckBoxExample_Test method testFindByLabelTextExact.
/**
* Test that ByLabel works for CheckBoxes by label text exact match.
*/
@Test
public void testFindByLabelTextExact() {
// Launch the web browser to the LDE
WebDriver driver = getDriver();
WContainer container = (WContainer) getUi();
WFieldLayout layout = (WFieldLayout) container.getChildAt(0);
WField field = (WField) layout.getChildAt(0);
String labelText = field.getLabel().getText();
String componentId = field.getField().getId();
WebElement checkBox = driver.findElement(new ByLabel(labelText, false));
Assert.assertNotNull("Unable to find checkbox by label text", checkBox);
Assert.assertEquals("Checkbox element ID does not match expected", componentId, checkBox.getAttribute("id"));
}
use of com.github.bordertech.wcomponents.WContainer in project wcomponents by BorderTech.
the class WLinkRenderer_Test method testDoPaintWithAction.
@Test
public void testDoPaintWithAction() throws IOException, SAXException, XpathException {
WContainer root = new WContainer();
WLink link = new WLink("test", "http://test");
WPanel target1 = new WPanel();
WPanel target2 = new WPanel();
root.add(link);
root.add(target1);
root.add(target2);
// No Targets (target itself)
link.setAction(new TestAction());
assertSchemaMatch(root);
assertXpathEvaluatesTo(link.getId(), "//ui:ajaxtrigger/@triggerId", root);
assertXpathEvaluatesTo("1", "count(//ui:ajaxtrigger/ui:ajaxtargetid)", root);
assertXpathEvaluatesTo(link.getId(), "//ui:ajaxtrigger/ui:ajaxtargetid[1]/@targetId", root);
// With Targets
link.setAction(new TestAction(), target1, target2);
assertSchemaMatch(root);
assertXpathEvaluatesTo(link.getId(), "//ui:ajaxtrigger/@triggerId", root);
assertXpathEvaluatesTo("2", "count(//ui:ajaxtrigger/ui:ajaxtargetid)", root);
assertXpathEvaluatesTo(target1.getId(), "//ui:ajaxtrigger/ui:ajaxtargetid[1]/@targetId", root);
assertXpathEvaluatesTo(target2.getId(), "//ui:ajaxtrigger/ui:ajaxtargetid[2]/@targetId", root);
}
use of com.github.bordertech.wcomponents.WContainer in project wcomponents by BorderTech.
the class WNumberFieldRenderer_Test method testDoPaint.
@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
WNumberField numberField = new WNumberField();
WButton button = new WButton("Test");
WContainer root = new WContainer();
root.add(numberField);
root.add(button);
assertSchemaMatch(numberField);
assertXpathEvaluatesTo(numberField.getId(), "//ui:numberfield/@id", numberField);
assertXpathNotExists("//ui:numberfield/@disabled", numberField);
assertXpathNotExists("//ui:numberfield/@hidden", numberField);
assertXpathNotExists("//ui:numberfield/@required", numberField);
assertXpathNotExists("//ui:numberfield/@readOnly", numberField);
assertXpathNotExists("//ui:numberfield/@toolTip", numberField);
assertXpathNotExists("//ui:numberfield/@accessibleText", numberField);
assertXpathNotExists("//ui:numberfield/@min", numberField);
assertXpathNotExists("//ui:numberfield/@max", numberField);
assertXpathNotExists("//ui:numberfield/@step", numberField);
assertXpathNotExists("//ui:numberfield/@decimals", numberField);
assertXpathNotExists("//ui:numberfield/@buttonId", numberField);
numberField.setDisabled(true);
assertSchemaMatch(numberField);
assertXpathEvaluatesTo("true", "//ui:numberfield/@disabled", numberField);
setFlag(numberField, ComponentModel.HIDE_FLAG, true);
assertSchemaMatch(numberField);
assertXpathEvaluatesTo("true", "//ui:numberfield/@hidden", numberField);
numberField.setMandatory(true);
assertSchemaMatch(numberField);
assertXpathEvaluatesTo("true", "//ui:numberfield/@required", numberField);
numberField.setToolTip("toolTip");
assertSchemaMatch(numberField);
assertXpathEvaluatesTo(numberField.getToolTip(), "//ui:numberfield/@toolTip", numberField);
numberField.setAccessibleText("accessibleText");
assertSchemaMatch(numberField);
assertXpathEvaluatesTo(numberField.getAccessibleText(), "//ui:numberfield/@accessibleText", numberField);
numberField.setMinValue(45);
assertSchemaMatch(numberField);
assertXpathEvaluatesTo("45", "//ui:numberfield/@min", numberField);
numberField.setMaxValue(50);
assertSchemaMatch(numberField);
assertXpathEvaluatesTo("50", "//ui:numberfield/@max", numberField);
numberField.setStep(0.5);
assertSchemaMatch(numberField);
assertXpathEvaluatesTo("0.5", "//ui:numberfield/@step", numberField);
numberField.setDecimalPlaces(2);
assertSchemaMatch(numberField);
assertXpathEvaluatesTo("2", "//ui:numberfield/@decimals", numberField);
numberField.setDefaultSubmitButton(button);
assertSchemaMatch(numberField);
assertXpathEvaluatesTo(button.getId(), "//ui:numberfield/@buttonId", numberField);
numberField.setNumber(123);
assertSchemaMatch(numberField);
assertXpathEvaluatesTo("123", "normalize-space(//ui:numberfield)", numberField);
}
Aggregations