Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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

 
And then we all jump out and yell "surprise! we got you this tiny ad!"
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic