Search in sources :

Example 21 with ExplanatoryText

use of com.github.bordertech.wcomponents.examples.common.ExplanatoryText in project wcomponents by BorderTech.

the class ColumnLayoutExample method addAutoWidthExample.

/**
 * This example shows a column which does not have widths set in Java. This is a "good thing": widths should be set in CSS.
 */
private void addAutoWidthExample() {
    add(new WHeading(HeadingLevel.H2, "Automatic (app defined) widths"));
    add(new ExplanatoryText("This example shows what happens if you use undefined (0) column width and do not then define them in CSS."));
    WPanel panel = new WPanel();
    panel.setLayout(new ColumnLayout(new int[] { 0, 0, 0 }, new Alignment[] { Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT }));
    add(panel);
    panel.add(new BoxComponent("Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."));
    panel.add(new BoxComponent("Praesent eu turpis convallis, fringilla elit nec, ullamcorper purus. Proin dictum ac nunc rhoncus fringilla. " + "Pellentesque habitant morbi tristique senectus et netus et malesuada fames."));
    panel.add(new BoxComponent("Vestibulum vehicula a turpis et efficitur. Integer maximus enim a orci posuere, id fermentum magna dignissim. " + "Sed condimentum, dui et condimentum faucibus, quam erat pharetra."));
    panel.add(new BoxComponent("Left"));
    panel.add(new BoxComponent("Center"));
    panel.add(new BoxComponent("Right"));
    add(new WHorizontalRule());
}
Also used : Alignment(com.github.bordertech.wcomponents.layout.ColumnLayout.Alignment) WPanel(com.github.bordertech.wcomponents.WPanel) ColumnLayout(com.github.bordertech.wcomponents.layout.ColumnLayout) ExplanatoryText(com.github.bordertech.wcomponents.examples.common.ExplanatoryText) WHeading(com.github.bordertech.wcomponents.WHeading) WHorizontalRule(com.github.bordertech.wcomponents.WHorizontalRule)

Example 22 with ExplanatoryText

use of com.github.bordertech.wcomponents.examples.common.ExplanatoryText in project wcomponents by BorderTech.

the class WCheckBoxSelectExample method addAntiPatternExamples.

/**
 * Examples of what not to do when using WCheckBoxSelect.
 */
private void addAntiPatternExamples() {
    add(new WHeading(HeadingLevel.H2, "WCheckBoxSelect anti-pattern examples"));
    add(new WMessageBox(WMessageBox.WARN, "These examples are purposely bad and should not be used as samples of how to use WComponents but samples of how NOT to use them."));
    add(new WHeading(HeadingLevel.H3, "WCheckBoxSelect with submitOnChange"));
    WFieldLayout layout = new WFieldLayout(WFieldLayout.LAYOUT_STACKED);
    add(layout);
    WCheckBoxSelect select = new WCheckBoxSelect("australian_state");
    select.setSubmitOnChange(true);
    layout.addField("Select a state or territory with auto save", select);
    select = new WCheckBoxSelect("australian_state");
    select.setSubmitOnChange(true);
    layout.addField("Select a state or territory with auto save and hint", select).getLabel().setHint("This is a hint");
    // Even compound controls need a label
    add(new WHeading(HeadingLevel.H3, "WCheckBoxSelect with no labelling component"));
    add(new ExplanatoryText("All input controls, even those which are complex and do not output labellable HTML elements, must be associated with" + " a WLabel or have a toolTip."));
    add(new WCheckBoxSelect("australian_state"));
    // Too many options anti-pattern
    add(new WHeading(HeadingLevel.H3, "WCheckBoxSelect with too many options"));
    add(new ExplanatoryText("Don't use a WCheckBoxSelect if you have more than a handful of options. A good rule of thumb is fewer than 10."));
    select = new WCheckBoxSelect(new String[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" });
    select.setButtonLayout(WCheckBoxSelect.LAYOUT_COLUMNS);
    select.setButtonColumns(6);
    select.setFrameless(true);
    add(new WLabel("Select your country of birth", select));
    add(select);
    add(new WHeading(HeadingLevel.H3, "WCheckBoxSelect with no options."));
    add(new ExplanatoryText("An interactive WCheckBoxSelect with no options is rather pointless."));
    select = new WCheckBoxSelect();
    add(new WLabel("WCheckBoxSelect with no options", select));
    add(select);
}
Also used : WMessageBox(com.github.bordertech.wcomponents.WMessageBox) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) ExplanatoryText(com.github.bordertech.wcomponents.examples.common.ExplanatoryText) WHeading(com.github.bordertech.wcomponents.WHeading) WCheckBoxSelect(com.github.bordertech.wcomponents.WCheckBoxSelect) WLabel(com.github.bordertech.wcomponents.WLabel)

Example 23 with ExplanatoryText

use of com.github.bordertech.wcomponents.examples.common.ExplanatoryText in project wcomponents by BorderTech.

the class WCheckBoxSelectExample method addSingleColumnSelectExample.

/**
 * adds a WCheckBoxSelect with LAYOUT_COLUMN in 1 column simply by not setting the number of columns. This is
 * superfluous as you should use LAYOUT_STACKED (the default) instead.
 */
private void addSingleColumnSelectExample() {
    add(new WHeading(HeadingLevel.H3, "WCheckBoxSelect laid out in a single column"));
    add(new ExplanatoryText("When layout is COLUMN, setting the layoutColumnCount property to one, or forgetting to set it at all (default is " + "one) is a little bit pointless."));
    final WCheckBoxSelect select = new WCheckBoxSelect("australian_state");
    select.setToolTip("Make a selection");
    select.setButtonLayout(WCheckBoxSelect.LAYOUT_COLUMNS);
    add(select);
}
Also used : ExplanatoryText(com.github.bordertech.wcomponents.examples.common.ExplanatoryText) WHeading(com.github.bordertech.wcomponents.WHeading) WCheckBoxSelect(com.github.bordertech.wcomponents.WCheckBoxSelect)

Example 24 with ExplanatoryText

use of com.github.bordertech.wcomponents.examples.common.ExplanatoryText in project wcomponents by BorderTech.

the class WLabelExample method addNestedFieldExamples.

/**
 * Examples showing WLabel with a nested input control WComponent.
 * This is VERY dangerous as only a very few WComponents are valid for this scenario. If you go down this route: stop!!
 * These are really here for framework testing, not as examples as to  how to do things.
 */
private void addNestedFieldExamples() {
    add(new WHeading(HeadingLevel.H2, "Label nesting which is technically OK"));
    /* Just because it is OK to do this does not mean you should! So these "examples" have far fewer comments. */
    WPanel errorLayoutPanel = new WPanel();
    errorLayoutPanel.setLayout(new FlowLayout(FlowLayout.VERTICAL, Size.LARGE));
    errorLayoutPanel.setMargin(new Margin(null, null, Size.XL, null));
    add(errorLayoutPanel);
    errorLayoutPanel.add(new ExplanatoryText("This example shows WLabels with a single nested simple form control WTextField." + " This is not a contravention of the HTML specification but you should not do it."));
    WLabel outerLabel = new WLabel("Label with nested WTextField and not 'for' anything");
    errorLayoutPanel.add(outerLabel);
    outerLabel.add(new WTextField());
    WTextField innerField = new WTextField();
    outerLabel = new WLabel("Label 'for' nested WTextField", innerField);
    errorLayoutPanel.add(outerLabel);
    outerLabel.add(innerField);
}
Also used : FlowLayout(com.github.bordertech.wcomponents.layout.FlowLayout) WPanel(com.github.bordertech.wcomponents.WPanel) ExplanatoryText(com.github.bordertech.wcomponents.examples.common.ExplanatoryText) WTextField(com.github.bordertech.wcomponents.WTextField) WHeading(com.github.bordertech.wcomponents.WHeading) Margin(com.github.bordertech.wcomponents.Margin) WLabel(com.github.bordertech.wcomponents.WLabel)

Example 25 with ExplanatoryText

use of com.github.bordertech.wcomponents.examples.common.ExplanatoryText 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);
}
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) WLabel(com.github.bordertech.wcomponents.WLabel)

Aggregations

ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)27 WHeading (com.github.bordertech.wcomponents.WHeading)26 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)11 WLabel (com.github.bordertech.wcomponents.WLabel)9 WPanel (com.github.bordertech.wcomponents.WPanel)8 WRadioButtonSelect (com.github.bordertech.wcomponents.WRadioButtonSelect)8 WButton (com.github.bordertech.wcomponents.WButton)7 WCheckBoxSelect (com.github.bordertech.wcomponents.WCheckBoxSelect)7 WTextField (com.github.bordertech.wcomponents.WTextField)6 WText (com.github.bordertech.wcomponents.WText)5 Action (com.github.bordertech.wcomponents.Action)4 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)4 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)4 ColumnLayout (com.github.bordertech.wcomponents.layout.ColumnLayout)4 FlowLayout (com.github.bordertech.wcomponents.layout.FlowLayout)4 WHorizontalRule (com.github.bordertech.wcomponents.WHorizontalRule)3 WImage (com.github.bordertech.wcomponents.WImage)3 WMessageBox (com.github.bordertech.wcomponents.WMessageBox)3 Alignment (com.github.bordertech.wcomponents.layout.ColumnLayout.Alignment)3 ValidatingAction (com.github.bordertech.wcomponents.validation.ValidatingAction)3