• 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

How to do two actions on a same Form in Struts?

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a form with two buttons - one for update and the other for delete.
since I can only define only one action in html:form, say <html:form action="/performupdate">, how do I do these two different actions? The action class for performupdate.do will do update. I dont know how to perform delete...
Any help please...?


Thx in adv
shakthi
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi sakthi

That is not much difficult task, you call a javascript function on click of the two buttons, and awritethe following code in the function

function gotoNext(chk)
{
if(chk =='update')
{
document.frm.X.action = /update.do;
document.frm.submit();
}
else
{

document.frm.X.action = /delete.do;
document.frm.submit();

}

}

pass chk on click of the button ,
Best Regards
Pankaj
 
Thillai Sakthi
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Pankaj....that works....
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is another way without using javascript. You can use the LookupDispatchAction class. Here is a example/referce

LookupDispatchAction
 
reply
    Bookmark Topic Watch Topic
  • New Topic