use of com.github.bordertech.wcomponents.WConfirmationButton 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.WConfirmationButton in project wcomponents by BorderTech.
the class WConfirmationButtonRenderer_Test method testRendererCorrectlyConfigured.
@Test
public void testRendererCorrectlyConfigured() {
WConfirmationButton component = new WConfirmationButton("dummy");
Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(component) instanceof WButtonRenderer);
}
use of com.github.bordertech.wcomponents.WConfirmationButton in project wcomponents by BorderTech.
the class WConfirmationButtonRenderer_Test method testDoPaint.
@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
WConfirmationButton button = new WConfirmationButton("dummy");
assertXpathExists("//html:button", button);
String message = "WConfirmationButton_Test.testRenderedFormat.message";
button.setMessage(message);
assertXpathEvaluatesTo(message, "//html:button/@data-wc-btnmsg", button);
}
use of com.github.bordertech.wcomponents.WConfirmationButton in project wcomponents by BorderTech.
the class WConfirmationButtonRenderer_Test method testXssEscaping.
@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
WConfirmationButton button = new WConfirmationButton(getMaliciousContent());
assertSafeContent(button);
button.setToolTip(getMaliciousAttribute("html:button"));
assertSafeContent(button);
button.setAccessibleText(getMaliciousAttribute("html:button"));
assertSafeContent(button);
button.setMessage(getMaliciousAttribute("html:button"));
assertSafeContent(button);
button.setImageUrl(getMaliciousAttribute());
assertSafeContent(button);
}
Aggregations