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?) } ... } }

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}