• 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

struts 2.0

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could any body please help me regarding how to call more than one action in a jsp page in struts 2.0 tag.e.g I have one struts 2.0 implemented jsp page in which I have three submit buttons.I want to call three different actions..so could this possible...please help me ASAP.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
U can do this using java script and buttons. this is the sample code given below.
use 3 buttons for each submit. when each button onclick event call separate javascript with different action. Pls try


Enjoy.............. struts 2
 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to understand your question. Are you trying to do:

a) You have a JSP with three different submit buttons on it. Each button goes to a different action. Each button is a different form

b) You have a JSP with three different submit buttons. Each button goes to a different action. The buttons are all in the same form.

If you're doing case "a", then nothing special should be needed. No JS is required. Simply having each form tag declare the appropriate action.

If you are doing case "b", then the above JS solution might be needed
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can do this by any of one
1. you can call one action, with differnt method names,like save, delete ,add button.
2. if you need to call different actions, just you can give actions name in your button' action property, can call seperate action for every button, In case you want to pass any parameters, then you can write Javascript method,its up to you
 
sudhansu sahoo
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Chatura for your reply...
I will implement according to your code.
But I am not getting the dojo stuffs.
Could you please let me know whether I need to add a jar file for this.
If yes,could you please let me know the corresponding jar file..

Thank You.
 
sudhansu sahoo
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Eric...I am talking about case b.Could you please send me the exact code for that...
Thank You.
 
sudhansu sahoo
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi selvaraju....

Whatever you have mentioned is fine with Struts 1.x.
It can be acheived with DispatchAction Class in that case.
But in case of struts 2.0 it is totally different.
So I want how to implement the same with Struts 2.0.
Could you please help regarding this....
 
sudhansu sahoo
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chatura...
Could you please do me a favour...
I am writing below my code snippet.
Could you please write the corresponding code to call the respective actions:

<TABLE border="0" cellpadding="0" cellspacing="0">
<BODY>
<TR>
<TD >
<s:submit value="Back To Search" action="backtosearch" />
</TD>
<TD>
<s:submit value="Main Page" action="mainpage" />
</TD>
<TD>
<s:submit value="Login" action="login" />
</TD>
</TR>
</BODY>
</TABLE>
 
selvaraju sellamuthu
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code is OK, Close with form tag.Then map your action in Struts.xml file like below
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic