This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes Call Action method from another Action Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Call Action method from another Action Class" Watch "Call Action method from another Action Class" New topic
Author

Call Action method from another Action Class

Saritha Penumudi
Ranch Hand

Joined: Aug 18, 2003
Posts: 147
Hi,
I am using DispatchAction for all my JSP forms.

Now, I have a scenario where I have to show same screen from n different places. That screen need some data that I have to get before I render UI on to the browser. Hence I have a setup method in the class that would go and get the data, hold that data in request scope and return ActionForward() to that Jsp page.

Now from all other screens I have to call this setup method. How can I forward request from one action to other?

Do this code make any sense.

public void performSomething(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response){
Action1 ac1 = new Action1();
ac1.setup(mapping,form,request,response); // will this work?

}

How such situations will be handled?

Thank you
Saritha
[ September 17, 2004: Message edited by: Saritha ventrapragada ]
Matt Sloan
Greenhorn

Joined: Aug 27, 2004
Posts: 26
what not put a forward tag to this new action that you want to call? To me that makes more sense.
Saritha Penumudi
Ranch Hand

Joined: Aug 18, 2003
Posts: 147
Thanks Matt,

I guess that is the best solution to handle that situation. By this we will not relay on Action class but on framework.

Thank you
Saritha
 
Consider Paul's rocket mass heater.
 
subject: Call Action method from another Action Class