Search in sources :

Example 31 with WContainer

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;
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer)

Example 32 with WContainer

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;
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer) Optional(com.github.bordertech.wcomponents.subordinate.Optional) WSubordinateControl(com.github.bordertech.wcomponents.subordinate.WSubordinateControl) WCheckBox(com.github.bordertech.wcomponents.WCheckBox) Equal(com.github.bordertech.wcomponents.subordinate.Equal) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) Rule(com.github.bordertech.wcomponents.subordinate.Rule) WTextField(com.github.bordertech.wcomponents.WTextField) WRadioButtonSelect(com.github.bordertech.wcomponents.WRadioButtonSelect) Mandatory(com.github.bordertech.wcomponents.subordinate.Mandatory)

Example 33 with WContainer

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"));
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WContainer(com.github.bordertech.wcomponents.WContainer) WField(com.github.bordertech.wcomponents.WField) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) WebElement(org.openqa.selenium.WebElement) ByLabel(com.github.bordertech.wcomponents.test.selenium.ByLabel) Test(org.junit.Test)

Example 34 with WContainer

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);
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer) WPanel(com.github.bordertech.wcomponents.WPanel) WLink(com.github.bordertech.wcomponents.WLink) TestAction(com.github.bordertech.wcomponents.TestAction) Test(org.junit.Test)

Example 35 with WContainer

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);
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer) WNumberField(com.github.bordertech.wcomponents.WNumberField) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Aggregations

WContainer (com.github.bordertech.wcomponents.WContainer)49 Test (org.junit.Test)41 WTextField (com.github.bordertech.wcomponents.WTextField)21 WCheckBox (com.github.bordertech.wcomponents.WCheckBox)17 Equal (com.github.bordertech.wcomponents.subordinate.Equal)16 Rule (com.github.bordertech.wcomponents.subordinate.Rule)16 WSubordinateControl (com.github.bordertech.wcomponents.subordinate.WSubordinateControl)16 SubordinateTarget (com.github.bordertech.wcomponents.SubordinateTarget)15 WButton (com.github.bordertech.wcomponents.WButton)14 GreaterThanOrEqual (com.github.bordertech.wcomponents.subordinate.GreaterThanOrEqual)14 LessThanOrEqual (com.github.bordertech.wcomponents.subordinate.LessThanOrEqual)14 NotEqual (com.github.bordertech.wcomponents.subordinate.NotEqual)14 SubordinateTrigger (com.github.bordertech.wcomponents.SubordinateTrigger)11 WComponentGroup (com.github.bordertech.wcomponents.WComponentGroup)10 Hide (com.github.bordertech.wcomponents.subordinate.Hide)10 Show (com.github.bordertech.wcomponents.subordinate.Show)10 WPanel (com.github.bordertech.wcomponents.WPanel)9 Diagnostic (com.github.bordertech.wcomponents.validation.Diagnostic)6 DiagnosticImpl (com.github.bordertech.wcomponents.validation.DiagnosticImpl)6 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)5