This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action 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
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

"two buttons, same value" problem

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I've got a .jsp page where I have two buttons with the value(label) "Save comment", however, these buttons save different types of comments so I need to know in my Action class which button was pressed. Or even have one Action for each button.
So far, I've not been able to figure out how to do this. Is there a property I can use or should I use nested:form? I'm not quite sure on how to use nested:form though.
Thanks for any help!
/Laura
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right now the button is passed as a parameter. The name of the parameter is the text displayed in your button.
If you can change the text of at least one of the buttons that would take care of your problem easy.
If you are allowed to use Javascript it that would work because each button call its own onsubmit method to add another parameter to the form.
If neither of those meets requirements, well here's my best guess.
I assume you have 2 commentboxes. You can look to see which one has inputted text and save it.
I'm not so sure you can attach different actions to each button without following one of my above solutions to go along with it.
I don't know much about nested:form as you suggested and I'm not excited about looking into it - gives me cold shivers to even think about it.
I've also seen programmers give a different name attribute for each button and have a getter/setter for each name. There's other tricks you'll need to access which button was clicked. One possibility is to have the method share a single String named button.
[ April 05, 2004: Message edited by: Marc Peabody ]
 
A day job? In an office? My worst nightmare! Comfort me tiny ad!
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!