Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Actions in Struts

 
Luciano Queiroz
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I call more than one Action from a HTML form?
For example, I have 3 buttons in my form: insert, delete and update. Is there any way I can use a parameter in each submit to call different Actions?
Thanks!
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Luciano,
as far as I do understand your question I would use just one Action containing a little logic to learn from the client what to do: delete, update or create. An alternative could be to create three different Actions called by three different forms on the client side.
Just my $0,02...
Regards
Berny Woehrlin
 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read up on the DispatchAction and LookupDispatchAction on Ted Husted's Struts Tips website.
Struts tips
 
Jesse Beaumont
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The way we do it is we dynamically rewrite the form's action attribute depending on which button was pressed and then post to a different action-mapping.
Using DispatchAction is a cleaner way of doing the same thing.
Jesse
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic