Search in sources :

Example 21 with WFieldLayout

use of com.github.bordertech.wcomponents.WFieldLayout in project wcomponents by BorderTech.

the class WRadioButtonSelectExample method addReadOnlyExamples.

/**
 * Examples of readonly states. When in a read only state only the selected option is output. Since a
 * WRadioButtonSeelct can only have 0 or 1 selected option the LAYOUT and FRAME are ignored.
 */
private void addReadOnlyExamples() {
    add(new WHeading(HeadingLevel.H3, "Read-only WRadioButtonSelect examples"));
    add(new ExplanatoryText("These examples all use the same list of options: the states and territories list from the editable examples above. " + "When the readOnly state is specified only that option which is selected is output.\n" + "Since no more than one option is able to be selected the layout and frame settings are ignored in the read only state."));
    WFieldLayout layout = new WFieldLayout();
    add(layout);
    WRadioButtonSelect select = new WRadioButtonSelect("australian_state");
    select.setReadOnly(true);
    layout.addField("Read only with no selection", select);
    select = new SelectWithSelection("australian_state");
    select.setReadOnly(true);
    layout.addField("Read only with selection", select);
}
Also used : WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) ExplanatoryText(com.github.bordertech.wcomponents.examples.common.ExplanatoryText) WRadioButtonSelect(com.github.bordertech.wcomponents.WRadioButtonSelect) WHeading(com.github.bordertech.wcomponents.WHeading)

Example 22 with WFieldLayout

use of com.github.bordertech.wcomponents.WFieldLayout in project wcomponents by BorderTech.

the class WCheckBoxExample_Test method testFindByLabelId.

/**
 * Test that ByLabel works for CheckBoxes by label id.
 */
@Test
public void testFindByLabelId() {
    // 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 labelId = field.getLabel().getId();
    String componentId = field.getField().getId();
    WebElement checkBox = driver.findElement(new ByLabel(labelId));
    Assert.assertNotNull("Unable to find checkbox by labelId", 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 23 with WFieldLayout

use of com.github.bordertech.wcomponents.WFieldLayout in project wcomponents by BorderTech.

the class AbstractSetMandatory_Test method testExecute.

@Test
public void testExecute() {
    // ---------------------
    // Valid Target (WInput) and TRUE Boolean Value
    SubordinateTarget target1 = new MyTarget();
    AbstractSetMandatory mandatory = new MyMandatory(target1, Boolean.TRUE);
    // Should be mandatory
    mandatory.execute();
    Assert.assertTrue("Target (Mandatable) should be mandatory", ((Mandatable) target1).isMandatory());
    // FALSE Boolean Value
    mandatory = new MyMandatory(target1, Boolean.FALSE);
    // Should not be mandatory
    mandatory.execute();
    Assert.assertFalse("Target (Mandatable) should not be mandatory", ((Mandatable) target1).isMandatory());
    // ---------------------
    // Valid Target (WField) and TRUE Boolean Value
    Input textArea = new WTextArea();
    WField target2 = new WFieldLayout().addField("test", textArea);
    mandatory = new MyMandatory(target2, Boolean.TRUE);
    // Should be mandatory
    mandatory.execute();
    Assert.assertTrue("Target (WField) should be mandatory", textArea.isMandatory());
    // FALSE Boolean Value
    mandatory = new MyMandatory(target2, Boolean.FALSE);
    // Should not be mandatory
    mandatory.execute();
    Assert.assertFalse("Target (WField) should not be mandatory", textArea.isMandatory());
    // ---------------------
    // Valid Target (WFieldSet) and TRUE Boolean Value
    WFieldSet target3 = new WFieldSet("Test");
    mandatory = new MyMandatory(target3, Boolean.TRUE);
    // Should be mandatory
    mandatory.execute();
    Assert.assertTrue("Target (WFieldSet) should be mandatory", target3.isMandatory());
    // FALSE Boolean Value
    mandatory = new MyMandatory(target3, Boolean.FALSE);
    // Should not be mandatory
    mandatory.execute();
    Assert.assertFalse("Target (WFieldSet) should not be mandatory", target3.isMandatory());
    // ---------------------
    // Invalid Target (Cannot be set Mandatory) and Boolean Value
    MyInvalidTarget target4 = new MyInvalidTarget();
    mandatory = new MyMandatory(target4, Boolean.TRUE);
    // Should do nothing
    mandatory.execute();
}
Also used : WTextArea(com.github.bordertech.wcomponents.WTextArea) SubordinateTarget(com.github.bordertech.wcomponents.SubordinateTarget) Input(com.github.bordertech.wcomponents.Input) WField(com.github.bordertech.wcomponents.WField) WFieldSet(com.github.bordertech.wcomponents.WFieldSet) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) Test(org.junit.Test)

Example 24 with WFieldLayout

use of com.github.bordertech.wcomponents.WFieldLayout in project wcomponents by BorderTech.

the class WFieldLayoutRenderer method doRender.

/**
 * Paints the given WFieldLayout.
 *
 * @param component the WFieldLayout to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WFieldLayout fieldLayout = (WFieldLayout) component;
    XmlStringBuilder xml = renderContext.getWriter();
    int labelWidth = fieldLayout.getLabelWidth();
    String title = fieldLayout.getTitle();
    xml.appendTagOpen("ui:fieldlayout");
    xml.appendAttribute("id", component.getId());
    xml.appendOptionalAttribute("class", component.getHtmlClass());
    xml.appendOptionalAttribute("track", component.isTracking(), "true");
    xml.appendOptionalAttribute("hidden", fieldLayout.isHidden(), "true");
    xml.appendOptionalAttribute("labelWidth", labelWidth > 0, labelWidth);
    xml.appendAttribute("layout", fieldLayout.getLayoutType());
    xml.appendOptionalAttribute("title", title);
    // Ordered layout
    if (fieldLayout.isOrdered()) {
        xml.appendAttribute("ordered", fieldLayout.getOrderedOffset());
    }
    xml.appendClose();
    // Render margin
    MarginRendererUtil.renderMargin(fieldLayout, renderContext);
    // Paint Fields
    paintChildren(fieldLayout, renderContext);
    xml.appendEndTag("ui:fieldlayout");
}
Also used : WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 25 with WFieldLayout

use of com.github.bordertech.wcomponents.WFieldLayout in project wcomponents by BorderTech.

the class WFieldLayoutRenderer_Test method testDoPaintBasic.

@Test
public void testDoPaintBasic() throws IOException, SAXException, XpathException {
    WFieldLayout layout = new WFieldLayout();
    // Validate Schema
    assertSchemaMatch(layout);
    // Check Attributes
    assertXpathEvaluatesTo(layout.getId(), "//ui:fieldlayout/@id", layout);
    assertXpathEvaluatesTo("flat", "//ui:fieldlayout/@layout", layout);
    assertXpathEvaluatesTo("", "//ui:fieldlayout/@hidden", layout);
    assertXpathEvaluatesTo("", "//ui:fieldlayout/@labelWidth", layout);
    assertXpathEvaluatesTo("", "//ui:fieldlayout/@title", layout);
    assertXpathEvaluatesTo("", "//ui:fieldlayout/@ordered", layout);
    // Check No Fields
    assertXpathNotExists("//ui:fieldlayout/ui:field", layout);
}
Also used : WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) Test(org.junit.Test)

Aggregations

WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)47 WHeading (com.github.bordertech.wcomponents.WHeading)18 Test (org.junit.Test)13 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)12 WButton (com.github.bordertech.wcomponents.WButton)11 WTextField (com.github.bordertech.wcomponents.WTextField)11 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)11 Margin (com.github.bordertech.wcomponents.Margin)10 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)10 WField (com.github.bordertech.wcomponents.WField)10 WFieldSet (com.github.bordertech.wcomponents.WFieldSet)10 Action (com.github.bordertech.wcomponents.Action)8 WRadioButtonSelect (com.github.bordertech.wcomponents.WRadioButtonSelect)7 WCheckBoxSelect (com.github.bordertech.wcomponents.WCheckBoxSelect)6 WCheckBox (com.github.bordertech.wcomponents.WCheckBox)5 WContainer (com.github.bordertech.wcomponents.WContainer)5 WLabel (com.github.bordertech.wcomponents.WLabel)5 WText (com.github.bordertech.wcomponents.WText)5 Equal (com.github.bordertech.wcomponents.subordinate.Equal)5 Rule (com.github.bordertech.wcomponents.subordinate.Rule)5