use of com.github.bordertech.wcomponents.WAjaxControl in project wcomponents by BorderTech.
the class WRadioButtonTriggerActionExample method setup.
/**
* Add controls to the UI.
*/
private void setup() {
setLayout(new FlowLayout(FlowLayout.VERTICAL));
WFieldSet fset = new WFieldSet("Select a meal");
add(fset);
fset.setMargin(new Margin(null, null, Size.LARGE, null));
WFieldLayout flay = new WFieldLayout(WFieldLayout.LAYOUT_STACKED);
fset.add(flay);
flay.setLabelWidth(0);
flay.addField("Breakfast", rb1);
flay.addField("Lunch", rb2);
flay.addField("Dinner", rb3);
/*
* NOTE: you should never use submitOnChange with a WRadioButton
*/
fset.add(new WAjaxControl(mealSelections, textBox));
mealSelections.setActionOnChange(new Action() {
@Override
public void execute(final ActionEvent event) {
String selection = null;
if (rb1.isSelected()) {
selection = "Breakfast selected";
}
if (rb2.isSelected()) {
selection = "Lunch selected";
}
if (rb3.isSelected()) {
selection = "Dinner selected";
}
text1.setText(selection + " : " + (new Date()).toString());
}
});
textBox.add(text1);
add(textBox);
add(mealSelections);
}
use of com.github.bordertech.wcomponents.WAjaxControl in project wcomponents by BorderTech.
the class GridLayoutOptionsExample method getLayoutControls.
/**
* build the list controls field set.
*
* @param errors the error box to be linked to the apply button.
* @return a field set for the controls.
*/
private WFieldSet getLayoutControls(final WValidationErrors errors) {
// Options Layout
WFieldSet fieldSet = new WFieldSet("List configuration");
WFieldLayout layout = new ControlFieldLayout();
fieldSet.add(layout);
// options.
columnCount.setDecimalPlaces(0);
columnCount.setMinValue(0);
columnCount.setNumber(DEFAULT_COLUMN_COUNT);
columnCount.setMandatory(true);
layout.addField("Number of Columns", columnCount);
rowCount.setDecimalPlaces(0);
rowCount.setMinValue(0);
rowCount.setNumber(DEFAULT_ROW_COUNT);
rowCount.setMandatory(true);
layout.addField("Number of Rows", rowCount);
hGap.setDecimalPlaces(0);
hGap.setMinValue(0);
hGap.setNumber(0);
hGap.setMandatory(true);
layout.addField("Horizontal Gap", hGap);
vGap.setDecimalPlaces(0);
vGap.setMinValue(0);
vGap.setNumber(0);
vGap.setMandatory(true);
layout.addField("Vertical Gap", vGap);
boxCount.setDecimalPlaces(0);
boxCount.setMinValue(0);
boxCount.setNumber(DEFAULT_BOX_COUNT);
boxCount.setMandatory(true);
layout.addField("Number of Boxes", boxCount);
layout.addField("Visible", cbVisible);
layout.addField("Allow responsive design", cbResponsive);
// Apply Button
WButton apply = new WButton("Apply");
apply.setAction(new ValidatingAction(errors, this) {
@Override
public void executeOnValid(final ActionEvent event) {
applySettings();
}
});
layout.addField(apply);
fieldSet.add(new WAjaxControl(apply, container));
fieldSet.setMargin(new Margin(null, null, Size.LARGE, null));
return fieldSet;
}
use of com.github.bordertech.wcomponents.WAjaxControl in project wcomponents by BorderTech.
the class TreePicker method buildUI.
/**
* Add all the bits in the right order.
*/
private void buildUI() {
add(new WSkipLinks());
// the application header
add(headerPanel);
headerPanel.add(new UtilityBar());
headerPanel.add(new WHeading(HeadingLevel.H1, "WComponents"));
// mainPanel holds the menu and the actual example.
add(mainPanel);
mainPanel.add(menuPanel);
mainPanel.add(exampleSection);
// An application footer?
WPanel footer = new WPanel(WPanel.Type.FOOTER);
footer.add(lastLoaded);
add(footer);
add(new WAjaxControl(menuPanel.getTree(), new AjaxTarget[] { menuPanel.getMenu(), exampleSection }));
}
use of com.github.bordertech.wcomponents.WAjaxControl 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.WAjaxControl 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));
}
Aggregations