use of com.github.bordertech.wcomponents.WTextField 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.WTextField in project wcomponents by BorderTech.
the class WSkipLinksExample method buildPanel.
/**
* Creates a panel for the example.
*
* @param title the panel title.
* @return a panel for use in the example.
*/
private WPanel buildPanel(final String title) {
WPanel panel = new WPanel(WPanel.Type.CHROME);
panel.setTitleText(title);
WProgressBar progress = new WProgressBar(18);
progress.setValue(15);
panel.add(progress);
panel.add(new WHorizontalRule());
WTextField input = new WTextField();
WLabel label = new WLabel("Text input", input);
panel.add(label);
panel.add(input);
return panel;
}
use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class DataTableBeanExample method createTable.
/**
* Creates and configures the table to be used by the example.
*
* @return a new configured table.
*/
private WDataTable createTable() {
WDataTable tbl = new WDataTable();
tbl.addColumn(new WTableColumn("First name", new WTextField()));
tbl.addColumn(new WTableColumn("Last name", new WTextField()));
tbl.addColumn(new WTableColumn("DOB", new WDateField()));
return tbl;
}
use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class SubordinateControlMandatoryExample method build.
/**
* Creates the component to be added to the validation container. This is doen in a static method because the
* component is passed into the superclass constructor.
*
* @return the component to be added to the validation container.
*/
private static WComponent build() {
WContainer root = new WContainer();
WSubordinateControl control = new WSubordinateControl();
root.add(control);
WFieldLayout layout = new WFieldLayout();
layout.setLabelWidth(25);
layout.setMargin(new com.github.bordertech.wcomponents.Margin(0, 0, 12, 0));
WCheckBox checkBox = new WCheckBox();
layout.addField("Set Mandatory", checkBox);
WTextField text = new WTextField();
layout.addField("Might need this field", text);
WTextField mandatoryField = new WTextField();
layout.addField("Another field always mandatory", mandatoryField);
mandatoryField.setMandatory(true);
final WRadioButtonSelect rbSelect = new WRadioButtonSelect("australian_state");
layout.addField("Select a state", rbSelect);
root.add(layout);
Rule rule = new Rule();
rule.setCondition(new Equal(checkBox, Boolean.TRUE.toString()));
rule.addActionOnTrue(new Mandatory(text));
rule.addActionOnFalse(new Optional(text));
rule.addActionOnTrue(new Mandatory(rbSelect));
rule.addActionOnFalse(new Optional(rbSelect));
control.addRule(rule);
return root;
}
use of com.github.bordertech.wcomponents.WTextField in project wcomponents by BorderTech.
the class TableLoadPerformance method setupWTable.
/**
* Setup WTable.
*/
private void setupWTable() {
WTextField col1 = new WTextField();
col1.setIdName("my1");
col1.setReadOnly(true);
WTextField col2 = new WTextField();
col2.setIdName("my2");
col2.setReadOnly(true);
WDateField col3 = new WDateField();
col3.setIdName("my3");
col3.setReadOnly(true);
table.addColumn(new WTableColumn("COL1", col1));
table.addColumn(new WTableColumn("COL2", col2));
table.addColumn(new WTableColumn("COL3", col3));
table.setExpandMode(WTable.ExpandMode.CLIENT);
table.setIdName("wt");
LevelDetails level = new LevelDetails("documents", TravelDocPanel.class, true);
SimpleBeanBoundTableModel model = new SimpleBeanBoundTableModel(new String[] { "firstName", "lastName", "dateOfBirth" }, level);
table.setTableModel(model);
}
Aggregations