use of com.github.bordertech.wcomponents.WAjaxControl in project wcomponents by BorderTech.
the class RepeaterExampleWithStaticIDs method createPrintContactsSubForm.
/**
* Create the UI artefacts for the "Print contacts" sub form.
*/
private void createPrintContactsSubForm() {
add(new WHeading(HeadingLevel.H3, "Print to CSV"));
WButton printBtn = new WButton("Print");
printBtn.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
printDetails();
}
});
printBtn.setImage("/image/document-print.png");
printBtn.setImagePosition(WButton.ImagePosition.EAST);
WFieldLayout layout = new WFieldLayout();
add(layout);
layout.setMargin(new Margin(Size.LARGE, null, null, null));
layout.addField("Print output", printOutput);
layout.addField((WLabel) null, printBtn);
add(new WAjaxControl(printBtn, printOutput));
}
use of com.github.bordertech.wcomponents.WAjaxControl in project wcomponents by BorderTech.
the class RepeaterExampleWithStaticIDs method createAddContactSubForm.
/**
* Create the UI artefacts for the "Add contact" sub form.
*/
private void createAddContactSubForm() {
add(new WHeading(HeadingLevel.H3, "Add a new contact"));
WButton addBtn = new WButton("Add");
addBtn.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
addNewContact();
}
});
addBtn.setImage("/image/address-book-new.png");
newNameField.setDefaultSubmitButton(addBtn);
WContainer container = new WContainer();
container.add(newNameField);
container.add(addBtn);
WFieldLayout layout = new WFieldLayout();
add(layout);
layout.addField("New contact name", container);
add(new WAjaxControl(addBtn, new AjaxTarget[] { repeater, newNameField }));
}
use of com.github.bordertech.wcomponents.WAjaxControl in project wcomponents by BorderTech.
the class TableRowEditingAjaxExample method setUpActionButtons.
/**
* Setup the action buttons and ajax controls in the action column.
*/
private void setUpActionButtons() {
// Buttons Panel
WPanel buttonPanel = new WPanel();
actionContainer.add(buttonPanel);
// Edit Button
final WButton editButton = new WButton("Edit") {
@Override
public boolean isVisible() {
Object key = TableUtil.getCurrentRowKey();
return !isEditRow(key);
}
};
editButton.setImage("/image/pencil.png");
editButton.setRenderAsLink(true);
editButton.setToolTip("Edit");
editButton.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
Object key = TableUtil.getCurrentRowKey();
addEditRow(key);
}
});
// Cancel Button
final WButton cancelButton = new WButton("Cancel") {
@Override
public boolean isVisible() {
Object key = TableUtil.getCurrentRowKey();
return isEditRow(key);
}
};
cancelButton.setImage("/image/cancel.png");
cancelButton.setRenderAsLink(true);
cancelButton.setToolTip("Cancel");
cancelButton.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
Object key = TableUtil.getCurrentRowKey();
removeEditRow(key);
firstNameField.reset();
lastNameField.reset();
dobField.reset();
}
});
// Delete Button
WConfirmationButton deleteButton = new WConfirmationButton("Delete") {
@Override
public boolean isVisible() {
Object key = TableUtil.getCurrentRowKey();
return !isEditRow(key);
}
};
deleteButton.setMessage("Do you want to delete row?");
deleteButton.setImage("/image/remove.png");
deleteButton.setRenderAsLink(true);
deleteButton.setToolTip("Delete");
deleteButton.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
Object key = TableUtil.getCurrentRowKey();
removeEditRow(key);
PersonBean bean = (PersonBean) actionContainer.getBean();
List<PersonBean> beans = (List<PersonBean>) table.getBean();
beans.remove(bean);
table.handleDataChanged();
messages.success(bean.getFirstName() + " " + bean.getLastName() + " removed.");
}
});
buttonPanel.add(editButton);
buttonPanel.add(cancelButton);
buttonPanel.add(deleteButton);
// Ajax - edit button
WAjaxControl editAjax = new WAjaxControl(editButton, new AjaxTarget[] { firstNameField, lastNameField, dobField, buttonPanel }) {
@Override
public boolean isVisible() {
return editButton.isVisible();
}
};
buttonPanel.add(editAjax);
// Ajax - cancel button
WAjaxControl cancelAjax = new WAjaxControl(cancelButton, new AjaxTarget[] { firstNameField, lastNameField, dobField, buttonPanel }) {
@Override
public boolean isVisible() {
return cancelButton.isVisible();
}
};
buttonPanel.add(cancelAjax);
buttonPanel.setIdName("buttons");
editAjax.setIdName("ajax_edit");
cancelAjax.setIdName("ajax_can");
editButton.setIdName("edit_btn");
cancelButton.setIdName("cancel_btn");
deleteButton.setIdName("delete_btn");
}
use of com.github.bordertech.wcomponents.WAjaxControl in project wcomponents by BorderTech.
the class WCheckBoxSelectExample method addInsideAFieldLayoutExamples.
/**
* When a WCheckBoxSelect is added to a WFieldLayout the legend is moved. The first CheckBoxSelect has a frame, the
* second doesn't
*/
private void addInsideAFieldLayoutExamples() {
add(new WHeading(HeadingLevel.H3, "WCheckBoxSelect inside a WFieldLayout"));
add(new ExplanatoryText("When a WCheckBoxSelect is inside a WField its label is exposed in a way which appears and behaves like a regular " + "HTML label. This allows WCheckBoxSelects to be used in a layout with simple form controls (such as WTextField) and produce a " + "consistent and predicatable interface. The third example in this set uses a null label and a toolTip to hide the labelling " + "element. This can lead to user confusion and is not recommended."));
WFieldLayout layout = new WFieldLayout();
layout.setLabelWidth(25);
add(layout);
String[] options = new String[] { "Dog", "Cat", "Bird", "Turtle" };
WCheckBoxSelect select = new WCheckBoxSelect(options);
layout.addField("Select some animals", select);
String[] options2 = new String[] { "Parrot", "Galah", "Cockatoo", "Lyre" };
select = new WCheckBoxSelect(options2);
layout.addField("Select some birds", select);
select.setFrameless(true);
// a tooltip can be used as a label stand-in even in a WField
String[] options3 = new String[] { "Carrot", "Beet", "Brocolli", "Bacon - the perfect vegetable" };
select = new WCheckBoxSelect(options3);
layout.addField((WLabel) null, select);
select.setToolTip("Veggies");
select = new WCheckBoxSelect("australian_state");
layout.addField("Select a state", select).getLabel().setHint("This is an ajax trigger");
add(new WAjaxControl(select, layout));
}
use of com.github.bordertech.wcomponents.WAjaxControl in project wcomponents by BorderTech.
the class WCheckBoxSelectExample method addExampleUsingArrayList.
/**
* This example creates the WCheckBoxSelect from a List of CarOptions.
*/
private void addExampleUsingArrayList() {
add(new WHeading(HeadingLevel.H3, "WCheckBoxSelect created using an array list of options"));
List<CarOption> options = new ArrayList<>();
options.add(new CarOption("1", "Ferrari", "F-360"));
options.add(new CarOption("2", "Mercedez Benz", "amg"));
options.add(new CarOption("3", "Nissan", "Skyline"));
options.add(new CarOption("5", "Toyota", "Prius"));
final WCheckBoxSelect select = new WCheckBoxSelect(options);
select.setToolTip("Cars");
final WTextField text = new WTextField();
text.setReadOnly(true);
text.setText(NO_SELECTION);
WButton update = new WButton("Select Cars");
update.setAction(new Action() {
@Override
public void execute(final ActionEvent event) {
String output = select.getSelected().isEmpty() ? NO_SELECTION : "The selected cars are: " + select.getSelected();
text.setText(output);
}
});
select.setDefaultSubmitButton(update);
add(select);
add(update);
add(text);
add(new WAjaxControl(update, text));
}
Aggregations