Search in sources :

Example 41 with WHeading

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

the class RepeaterExampleWithEditableRows method createExampleUi.

/**
 * Add all the required UI artefacts for this example.
 */
private void createExampleUi() {
    add(new WHeading(HeadingLevel.H2, "Contacts"));
    add(repeater);
    WButton addBtn = new WButton("Add");
    addBtn.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            addNewContact();
        }
    });
    newNameField.setDefaultSubmitButton(addBtn);
    WButton printBtn = new WButton("Print");
    printBtn.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            printEditedDetails();
        }
    });
    WFieldLayout layout = new WFieldLayout();
    add(layout);
    layout.addField("New contact name", newNameField);
    layout.addField((WLabel) null, addBtn);
    layout.addField("Print output", console);
    layout.addField((WLabel) null, printBtn);
    // Ajax controls to make things zippier
    add(new WAjaxControl(addBtn, new AjaxTarget[] { repeater, newNameField }));
    add(new WAjaxControl(printBtn, console));
}
Also used : Action(com.github.bordertech.wcomponents.Action) WAjaxControl(com.github.bordertech.wcomponents.WAjaxControl) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) WButton(com.github.bordertech.wcomponents.WButton) WHeading(com.github.bordertech.wcomponents.WHeading) AjaxTarget(com.github.bordertech.wcomponents.AjaxTarget)

Example 42 with WHeading

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

the class WCheckBoxSelectExample method addDisabledExamples.

/**
 * Examples of disabled state. You should use {@link WSubordinateControl} to set and manage the disabled state
 * unless there is no facility for the user to enable a control.
 */
private void addDisabledExamples() {
    add(new WHeading(HeadingLevel.H2, "Disabled WCheckBoxSelect examples"));
    WFieldLayout layout = new WFieldLayout();
    add(layout);
    WCheckBoxSelect select = new WCheckBoxSelect("australian_state");
    select.setDisabled(true);
    layout.addField("Disabled with no default selection", select);
    add(new WHeading(HeadingLevel.H3, "Disabled with no selection and no frame"));
    select = new WCheckBoxSelect("australian_state");
    select.setDisabled(true);
    select.setFrameless(true);
    layout.addField("Disabled with no selection and no frame", select);
    select = new SelectWithSingleSelected("australian_state");
    select.setDisabled(true);
    layout.addField("Disabled with one selection", select);
    select = new SelectWithManySelected("australian_state");
    select.setDisabled(true);
    select.setButtonLayout(WCheckBoxSelect.LAYOUT_COLUMNS);
    select.setButtonColumns(3);
    layout.addField("Disabled with many selections and COLUMN layout", select);
}
Also used : WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) WHeading(com.github.bordertech.wcomponents.WHeading) WCheckBoxSelect(com.github.bordertech.wcomponents.WCheckBoxSelect)

Example 43 with WHeading

use of com.github.bordertech.wcomponents.WHeading 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 44 with WHeading

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

the class WCheckBoxSelectExample method addExampleUsingLookupTable.

/**
 * This example creates the WCheckBoxSelect using an a look up table. All other optional properties are in their default state.
 * <p>Note for Framework devs: the unit tests for this Example are used to test the Selenium WebElement extension and this example is expected
 * to be: the first WCheckBoxSelect in the example; and to be interactive; and to have the 9 options of the "australian_state" lookup table.
 */
private void addExampleUsingLookupTable() {
    add(new WHeading(HeadingLevel.H3, "WCheckBoxSelect created using a lookup table"));
    final WCheckBoxSelect select = new WCheckBoxSelect("australian_state");
    final WTextField text = new WTextField();
    text.setReadOnly(true);
    text.setText(NO_SELECTION);
    WButton update = new WButton("Select");
    update.setAction(new Action() {

        @Override
        public void execute(final ActionEvent event) {
            String output = select.getSelected().isEmpty() ? NO_SELECTION : "The selected states are: " + select.getSelected();
            text.setText(output);
        }
    });
    select.setDefaultSubmitButton(update);
    add(new WLabel("Select a state or territory", select));
    add(select);
    add(update);
    add(text);
    add(new WAjaxControl(update, text));
}
Also used : Action(com.github.bordertech.wcomponents.Action) WAjaxControl(com.github.bordertech.wcomponents.WAjaxControl) ActionEvent(com.github.bordertech.wcomponents.ActionEvent) WTextField(com.github.bordertech.wcomponents.WTextField) WButton(com.github.bordertech.wcomponents.WButton) WHeading(com.github.bordertech.wcomponents.WHeading) WCheckBoxSelect(com.github.bordertech.wcomponents.WCheckBoxSelect) WLabel(com.github.bordertech.wcomponents.WLabel)

Example 45 with WHeading

use of com.github.bordertech.wcomponents.WHeading 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)

Aggregations

WHeading (com.github.bordertech.wcomponents.WHeading)53 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)26 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)18 WPanel (com.github.bordertech.wcomponents.WPanel)17 WButton (com.github.bordertech.wcomponents.WButton)16 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)13 WLabel (com.github.bordertech.wcomponents.WLabel)13 Action (com.github.bordertech.wcomponents.Action)12 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)12 WCheckBoxSelect (com.github.bordertech.wcomponents.WCheckBoxSelect)12 WRadioButtonSelect (com.github.bordertech.wcomponents.WRadioButtonSelect)10 WTextField (com.github.bordertech.wcomponents.WTextField)10 WText (com.github.bordertech.wcomponents.WText)9 ColumnLayout (com.github.bordertech.wcomponents.layout.ColumnLayout)7 FlowLayout (com.github.bordertech.wcomponents.layout.FlowLayout)7 WHorizontalRule (com.github.bordertech.wcomponents.WHorizontalRule)6 Test (org.junit.Test)5 Margin (com.github.bordertech.wcomponents.Margin)4 Alignment (com.github.bordertech.wcomponents.layout.ColumnLayout.Alignment)4 ValidatingAction (com.github.bordertech.wcomponents.validation.ValidatingAction)4