Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

how to decide which button is submitted in an action class

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Satish Kumar
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear David O'Meara
i hope it's fine now.
 
Satish Kumar
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that i cannot use javascript. is there anyother way to achieve this?
 
Shilpa Tendulkar
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Satish Kumar
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any suggestions please..! on this topic.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic