• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Handling Multiple Buttons in Struts

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm developing web application using jsp, struts, and hibernate. My jsp page having three buttons(add,edit,delete). I want to check which button clicked and get the button name or value to action class. I tried several ways but faild. I'm new to this area and still cannot find the answer. This is my jsp page(test.jsp)



testActionForm.java


testAction.java



got the error
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use DispatchAction or LookUpDispatchAction(with this you can use only multiple buttons which has business logic in the same class).. if you still want to use image buttons use EventDispatchAction..
I gues this is what you have asked.. if this is not you have asked show your struts-config.xml...
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am not sure about using images for the buttons.

But for simple HTML buttons here is what you can do.

In your jsp code, specify the buttons as :



(The display names for buttons is specified in the properties file here.)

In your actionform make a property as button and generate getter/setter.

Then in your Action class :



and so on.

Hope this helps you.
 
zuishi dilmo
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thnx for your replies. I tried Prakash Atturs method. It's working. You saved my time. Thank you so much. This link also very helpfull.

http://www.vaannila.com/struts/struts-example/struts-dispatch-action-example-1.html

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic