Over a million developers have joined DZone.

Webwork2 Multiple Buttons In Form

·
To react on multiple buttons in webforms use the following if you don't want to depend on the value attribute of the button (think of i18n):

And in the action: class FooAction implements Action { private Map buttonAction = new HashMap(); public Map getButtonAction() { return buttonAction; } public String execute() { if(buttonAction.containsKey("ok") { // ok was pressed } else if (buttonAction.containsKey("cancel") { // cancel was } else { // no button was pressed (enter key?) } ... } }
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}