Detecting button value

Posted on 2006-10-19
Last Modified: 2010-04-01
Hi experts,

Is there any way that I can detect button's value attribute in html:submit? for example:

          <td align="center"><html:submit  property="method" value="Save"/></td>
          <td align="center"><html:submit  property="method" value="Update"/></td>

How do detect whether user press save button or update button in side of ActionForward?

Question by:dkim18
LVL 10

Expert Comment

ID: 17770012
use lookup dispatch action

Author Comment

ID: 17770108
That is not my intention here.  ;-) I am asking this to solve specific task.
Probably I can use javascript and java code inside of jsp, but I am looking for better way of doing this.

Author Comment

ID: 17770136
Hm...calling execute method inside of save/update method is a good idea?
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

LVL 10

Accepted Solution

jaggernat earned 84 total points
ID: 17770445
>>> execute method inside of save/update method is a good idea?

you will not have a execute method inside save or update method.

your save or update methods are mapped to the names of the Buttons which you give in the jsp and that is why we use lookupdispatch action class.

LVL 11

Assisted Solution

Manish earned 83 total points
ID: 17794103
Change submit buttons to only button and on submit call javascript where you can pass hidden value for save or update and submit the form.

Assisted Solution

amateur83 earned 83 total points
ID: 17855279
karanw is right. U may try something like below:

in JSP
<html-el:button property="Save" onclick="onSaveClick(this.form);"><bean:message key=""/>
<html-el:button property="Update" onclick="onUpdateClick(this.form);"><bean:message key=""/>

in JS
function onSaveClick(form)
      form.action = saveAction;

function onUpdateClick(form)
      form.action = updateAction;

and then back to the JSP that will forward to specific action

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
getting param value 7 57
How to Make JSP Pages Responsive ? details are below 3 898
how to hide hide popup page refresh second time? 10 141
print map entry 34 72
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This article explains the steps required to use the default Photos screensaver to display branding/corporate images
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below.…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question