aspose file tools*
The moose likes Struts and the fly likes struts 2.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts 2.0 " Watch "struts 2.0 " New topic
Author

struts 2.0

sudhansu sahoo
Greenhorn

Joined: Feb 25, 2008
Posts: 8
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.
Chathura Ranasinghe
Greenhorn

Joined: Feb 17, 2008
Posts: 8
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
Eric Nielsen
Ranch Hand

Joined: Dec 14, 2004
Posts: 194
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
selvaraju sellamuthu
Ranch Hand

Joined: Jun 28, 2007
Posts: 53
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

Joined: Feb 25, 2008
Posts: 8
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

Joined: Feb 25, 2008
Posts: 8
Hi Eric...I am talking about case b.Could you please send me the exact code for that...
Thank You.
sudhansu sahoo
Greenhorn

Joined: Feb 25, 2008
Posts: 8
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

Joined: Feb 25, 2008
Posts: 8
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

Joined: Jun 28, 2007
Posts: 53
Your code is OK, Close with form tag.Then map your action in Struts.xml file like below
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts 2.0