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);
}
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());
}
Aggregations