Search in sources :

Example 26 with WFieldLayout

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

the class WFieldLayoutRenderer_Test method testDoPaintAllOptions.

@Test
public void testDoPaintAllOptions() throws IOException, SAXException, XpathException {
    WFieldLayout layout = new WFieldLayout(WFieldLayout.LAYOUT_STACKED);
    setFlag(layout, ComponentModel.HIDE_FLAG, true);
    layout.setLabelWidth(10);
    layout.setTitle("title1");
    // Validate Schema
    assertSchemaMatch(layout);
    // Check Attributes
    assertXpathEvaluatesTo(layout.getId(), "//ui:fieldlayout/@id", layout);
    assertXpathEvaluatesTo("stacked", "//ui:fieldlayout/@layout", layout);
    assertXpathEvaluatesTo("true", "//ui:fieldlayout/@hidden", layout);
    assertXpathEvaluatesTo("10", "//ui:fieldlayout/@labelWidth", layout);
    assertXpathEvaluatesTo("title1", "//ui:fieldlayout/@title", layout);
    // Check No Fields
    assertXpathNotExists("//ui:fieldlayout/ui:field", layout);
    // Set Label Width - 0
    layout.setLabelWidth(0);
    assertXpathEvaluatesTo("", "//ui:fieldlayout/@labelWidth", layout);
    // Set Label Width - 1
    layout.setLabelWidth(1);
    assertXpathEvaluatesTo("1", "//ui:fieldlayout/@labelWidth", layout);
    // Set Label Width - 100
    layout.setLabelWidth(100);
    assertXpathEvaluatesTo("100", "//ui:fieldlayout/@labelWidth", layout);
    // Set ordered
    layout.setOrdered(true);
    assertSchemaMatch(layout);
    assertXpathEvaluatesTo("1", "//ui:fieldlayout/@ordered", layout);
    // Set offset
    layout.setOrderedOffset(20);
    assertXpathEvaluatesTo("20", "//ui:fieldlayout/@ordered", layout);
}
Also used : WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) Test(org.junit.Test)

Example 27 with WFieldLayout

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

the class WFieldLayoutRenderer_Test method testXssEscaping.

@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
    WFieldLayout layout = new WFieldLayout();
    layout.setTitle(getMaliciousAttribute("ui:fieldlayout"));
    assertSafeContent(layout);
}
Also used : WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) Test(org.junit.Test)

Example 28 with WFieldLayout

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

the class WFieldLayoutRenderer_Test method testRendererCorrectlyConfigured.

/**
 * Test the Layout is correctly configured.
 */
@Test
public void testRendererCorrectlyConfigured() {
    WFieldLayout layout = new WFieldLayout();
    Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(layout) instanceof WFieldLayoutRenderer);
}
Also used : WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) Test(org.junit.Test)

Example 29 with WFieldLayout

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

the class WFieldLayoutRenderer_Test method testRenderedWithMargins.

@Test
public void testRenderedWithMargins() throws IOException, SAXException, XpathException {
    WFieldLayout layout = new WFieldLayout();
    assertXpathNotExists("//ui:fieldlayout/ui:margin", layout);
    Margin margin = new Margin(0);
    layout.setMargin(margin);
    assertXpathNotExists("//ui:fieldlayout/ui:margin", layout);
    margin = new Margin(Size.SMALL);
    layout.setMargin(margin);
    assertSchemaMatch(layout);
    assertXpathEvaluatesTo("sm", "//ui:fieldlayout/ui:margin/@all", layout);
    assertXpathEvaluatesTo("", "//ui:fieldlayout/ui:margin/@north", layout);
    assertXpathEvaluatesTo("", "//ui:fieldlayout/ui:margin/@east", layout);
    assertXpathEvaluatesTo("", "//ui:fieldlayout/ui:margin/@south", layout);
    assertXpathEvaluatesTo("", "//ui:fieldlayout/ui:margin/@west", layout);
    margin = new Margin(Size.SMALL, Size.MEDIUM, Size.LARGE, Size.XL);
    layout.setMargin(margin);
    assertSchemaMatch(layout);
    assertXpathEvaluatesTo("", "//ui:fieldlayout/ui:margin/@all", layout);
    assertXpathEvaluatesTo("sm", "//ui:fieldlayout/ui:margin/@north", layout);
    assertXpathEvaluatesTo("med", "//ui:fieldlayout/ui:margin/@east", layout);
    assertXpathEvaluatesTo("lg", "//ui:fieldlayout/ui:margin/@south", layout);
    assertXpathEvaluatesTo("xl", "//ui:fieldlayout/ui:margin/@west", layout);
}
Also used : WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) Margin(com.github.bordertech.wcomponents.Margin) Test(org.junit.Test)

Example 30 with WFieldLayout

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

the class AccordionExample method constructExample.

/**
 * Helper to do the work of the constructor since we do not really want to call over-rideable methods in a
 * constructor.
 */
private void constructExample() {
    add(new WHeading(HeadingLevel.H3, "ACCORDION tabs"));
    WTabSet tabset1c = new SampleWTabset(TabSetType.ACCORDION);
    add(tabset1c);
    /* Content height */
    add(new WHeading(HeadingLevel.H2, "Examples showing content height property."));
    add(new WHeading(HeadingLevel.H3, "Tall content."));
    WTabSet htabset1c = new SampleWTabset(TabSetType.ACCORDION);
    htabset1c.setContentHeight(TALL_CONTENT);
    add(htabset1c);
    add(new WHeading(HeadingLevel.H3, "Short content."));
    WTabSet htabset1g = new SampleWTabset(TabSetType.ACCORDION);
    htabset1g.setContentHeight(SHORT_CONTENT);
    add(htabset1g);
    add(new WHeading(HeadingLevel.H2, "Examples showing accordion's single property."));
    WTabSet singleOpenAccordionabset = new SampleWTabset(WTabSet.TYPE_ACCORDION);
    singleOpenAccordionabset.setSingle(true);
    add(singleOpenAccordionabset);
    add(new WHeading(HeadingLevel.H2, "Using WSubordinateControl"));
    WTabSet targetTabset = new SampleWTabset(TabSetType.ACCORDION);
    add(targetTabset);
    WFieldLayout layout = new WFieldLayout(WFieldLayout.LAYOUT_STACKED);
    add(layout);
    final WCheckBox disabledControllerCb = new WCheckBox();
    final WCheckBox hiddenControllerCb = new WCheckBox();
    layout.addField("disable tabset", disabledControllerCb);
    layout.addField("hide tabset", hiddenControllerCb);
    // Build & add the subordinate
    SubordinateBuilder builder = new SubordinateBuilder();
    builder.condition().equals(hiddenControllerCb, String.valueOf(true));
    builder.whenTrue().hide(targetTabset);
    builder.whenFalse().show(targetTabset);
    add(builder.build());
    builder = new SubordinateBuilder();
    builder.condition().equals(disabledControllerCb, String.valueOf(true));
    builder.whenTrue().disable(targetTabset);
    builder.whenFalse().enable(targetTabset);
    add(builder.build());
}
Also used : WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) SubordinateBuilder(com.github.bordertech.wcomponents.subordinate.builder.SubordinateBuilder) WCheckBox(com.github.bordertech.wcomponents.WCheckBox) WHeading(com.github.bordertech.wcomponents.WHeading) WTabSet(com.github.bordertech.wcomponents.WTabSet)

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