use of com.github.bordertech.wcomponents.WButton 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));
}
use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class RepeaterExampleWithStaticIDs method createButtonBar.
/**
* Create the UI artefacts for the update and reset buttons.
*/
private void createButtonBar() {
// Update and reset controls for the repeater.
WPanel buttonPanel = new WPanel(WPanel.Type.FEATURE);
buttonPanel.setMargin(new Margin(Size.MEDIUM, null, Size.LARGE, null));
buttonPanel.setLayout(new BorderLayout());
WButton updateButton = new WButton("Update");
updateButton.setImage("/image/document-save-5.png");
updateButton.setImagePosition(WButton.ImagePosition.EAST);
buttonPanel.add(updateButton, BorderLayout.EAST);
WButton resetButton = new WButton("Reset");
resetButton.setImage("/image/edit-undo-8.png");
resetButton.setImagePosition(WButton.ImagePosition.WEST);
resetButton.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
repeater.setData(fetchDataList());
}
});
buttonPanel.add(resetButton, BorderLayout.WEST);
add(buttonPanel);
add(new WAjaxControl(updateButton, repeater));
add(new WAjaxControl(resetButton, repeater));
}
use of com.github.bordertech.wcomponents.WButton 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));
}
use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class WConfirmationButtonExample method addAjaxExample.
/**
* This is used to reproduce a WComponents bug condition to make sure we do not re-create it once it is fixed.
* See https://github.com/BorderTech/wcomponents/issues/1266.
*/
private void addAjaxExample() {
add(new WHeading(HeadingLevel.H2, "Confirm as ajax trigger"));
final String before = "Before";
final String after = "After";
final WText ajaxContent = new WText("Before");
final WPanel target = new WPanel(WPanel.Type.BOX);
add(target);
target.add(ajaxContent);
WButton confirmWithAjax = new WButton("Replace");
confirmWithAjax.setMessage("Are you sure?");
confirmWithAjax.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
ajaxContent.setText(before.equals(ajaxContent.getText()) ? after : before);
}
});
add(confirmWithAjax);
add(new WAjaxControl(confirmWithAjax, target));
}
use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class WRadioButtonSelectExample method makeSimpleExample.
/**
* Make a simple editable example. The label for this example is used to get the example for use in the unit tests.
*/
private void makeSimpleExample() {
add(new WHeading(HeadingLevel.H3, "Simple WRadioButtonSelect"));
WPanel examplePanel = new WPanel();
examplePanel.setLayout(new FlowLayout(FlowLayout.VERTICAL, Size.MEDIUM));
add(examplePanel);
/**
* The radio button select.
*/
final WRadioButtonSelect rbSelect = new WRadioButtonSelect("australian_state");
final WTextField text = new WTextField();
text.setReadOnly(true);
text.setText(NO_SELECTION);
WButton update = new WButton("Update");
update.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
text.setText("The selected item is: " + rbSelect.getSelected());
}
});
// setting the default submit button improves usability. It can be set on a WPanel or the WRadioButtonSelect directly
examplePanel.setDefaultSubmitButton(update);
examplePanel.add(new WLabel("Select a state or territory", rbSelect));
examplePanel.add(rbSelect);
examplePanel.add(text);
examplePanel.add(update);
add(new WAjaxControl(update, text));
}
Aggregations