Search in sources :

Example 56 with WHeading

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

the class WButtonExample method addDefaultSubmitButtonExample.

/**
 * Examples showing how to set a WButton as the default submit button for an input control.
 */
private void addDefaultSubmitButtonExample() {
    add(new WHeading(HeadingLevel.H3, "Default submit button"));
    add(new ExplanatoryText("This example shows how to use an image as the only content of a WButton. " + "In addition this text field submits the entire screen using the image button to the right of the field."));
    // We use WFieldLayout to lay out a label:input pair. In this case the input is a
    // compound control of a WTextField and a WButton.
    WFieldLayout imageButtonFieldLayout = new WFieldLayout();
    imageButtonFieldLayout.setLabelWidth(25);
    add(imageButtonFieldLayout);
    // the text field and the button both need to be defined explicitly to be able to add them into a wrapper
    WTextField textFld = new WTextField();
    // and finally we get to the actual button
    WButton button = new WButton("Flag this record for follow-up");
    button.setImage("/image/flag.png");
    button.getImageHolder().setCacheKey("eg-button-flag");
    button.setActionObject(button);
    button.setAction(new ExampleButtonAction());
    // we can set the image button to be the default submit button for the text field.
    textFld.setDefaultSubmitButton(button);
    // There are many way of putting multiple controls in to a WField's input.
    // We are using a WContainer is the one which is lowest impact in the UI.
    WContainer imageButtonFieldContainer = new WContainer();
    imageButtonFieldContainer.add(textFld);
    // Use a WText to push the button off of the text field by an appropriate (user-agent determined) amount.
    // an en space is half an em. a none-breaking space \u00a0 could also be used but will have no effect on inter-node wrapping
    imageButtonFieldContainer.add(new WText("\u2002"));
    imageButtonFieldContainer.add(button);
    // Finally add the input wrapper to the WFieldLayout
    imageButtonFieldLayout.addField("Enter record ID", imageButtonFieldContainer);
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer) WText(com.github.bordertech.wcomponents.WText) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) ExplanatoryText(com.github.bordertech.wcomponents.examples.common.ExplanatoryText) WTextField(com.github.bordertech.wcomponents.WTextField) WButton(com.github.bordertech.wcomponents.WButton) WHeading(com.github.bordertech.wcomponents.WHeading)

Example 57 with WHeading

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

WHeading (com.github.bordertech.wcomponents.WHeading)57 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)27 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)21 WPanel (com.github.bordertech.wcomponents.WPanel)18 WButton (com.github.bordertech.wcomponents.WButton)16 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)15 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 WText (com.github.bordertech.wcomponents.WText)10 WTextField (com.github.bordertech.wcomponents.WTextField)10 ColumnLayout (com.github.bordertech.wcomponents.layout.ColumnLayout)7 FlowLayout (com.github.bordertech.wcomponents.layout.FlowLayout)7 Margin (com.github.bordertech.wcomponents.Margin)6 WHorizontalRule (com.github.bordertech.wcomponents.WHorizontalRule)6 WMessageBox (com.github.bordertech.wcomponents.WMessageBox)4 Alignment (com.github.bordertech.wcomponents.layout.ColumnLayout.Alignment)4 ValidatingAction (com.github.bordertech.wcomponents.validation.ValidatingAction)4