File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Call Action method from another Action Class