aspose file tools
The moose likes Struts and the fly likes how  to decide which button is submitted in an action class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "how  to decide which button is submitted in an action class" Watch "how  to decide which button is submitted in an action class" New topic
Author

how to decide which button is submitted in an action class

Satish Kumar
Ranch Hand

Joined: Oct 16, 2006
Posts: 84
My page has 2 buttons in one form. One is the submit1 button, another one is a submit2 button.
I use <html:img> or <html:image> tags for the buttons. I was wondering how I could get my action to determine which button was clicked and have the forward subsequently use the right method in my action.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"satish_t",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with display names get deleted, often without warning

thanks,
Dave
Shilpa Tendulkar
Ranch Hand

Joined: Jul 29, 2001
Posts: 75
Originally posted by satish_t:
My page has 2 buttons in one form. One is the submit1 button, another one is a submit2 button.
I use <html:img> or <html:image> tags for the buttons. I was wondering how I could get my action to determine which button was clicked and have the forward subsequently use the right method in my action.


you can pass some hidden action value which will determine which button was clicked. use onclick event on html:img or html:image tag to set the action value.

Hope this helps


SCJP5
Satish Kumar
Ranch Hand

Joined: Oct 16, 2006
Posts: 84
Dear David O'Meara
i hope it's fine now.
Satish Kumar
Ranch Hand

Joined: Oct 16, 2006
Posts: 84
The problem is that i cannot use javascript. is there anyother way to achieve this?
Shilpa Tendulkar
Ranch Hand

Joined: Jul 29, 2001
Posts: 75
Originally posted by satish kumar:
The problem is that i cannot use javascript. is there anyother way to achieve this?


you can use property and value attribute of html:image tag to find out which button was clicked.
Satish Kumar
Ranch Hand

Joined: Oct 16, 2006
Posts: 84
Originally posted by Shilpa Tendulkar:


you can use property and value attribute of html:image tag to find out which button was clicked.


its not working this way. when i tried its giving null in the action class when i give request.getParameter("submit"). May i know its working for you? if yes could you please send the sample code.
RoshaniG Gopal
Ranch Hand

Joined: May 15, 2006
Posts: 180
Hi Satish,
Using LookUpDispatchAction would solve all your problems and would give you scalaibity also. Please find the following link.
http://husted.com/struts/tips/003.html
If there is any problem, post your problem.
Regards,
Roshani


Regards,<br />Roshani
Satish Kumar
Ranch Hand

Joined: Oct 16, 2006
Posts: 84
Hi Roshani,
I am using LookupDispatchAction only. I need to identify which button is being clicked using the <html:image> tag. i HAVE A SET OF BUTTONS and need to get the value in the bean or any scope.
Satish Kumar
Ranch Hand

Joined: Oct 16, 2006
Posts: 84
Any suggestions please..! on this topic.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to decide which button is submitted in an action class
 
Similar Threads
Getting new browser window to open
How to keep a button from submitting a form.
how to tell which icon was clicked in the action class?
Multiple buttons in a form
Getting new browser window to open