Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing multiple actions one after another

Tags:

struts2

struts

I am in need of a way of executing multiple struts actions with one request. The goal is to minimize the need of request against the server. So what i need is something like a "MultiAction" which gets a list of actions as its parameters which it should execute and then return a "combined" result of this actions.

For example:

  • The client is split up in a lot of modules
  • One module needs to get information from the server
  • There is a proxy at the client handling this request
  • This proxy now goes and say "Hey you other modules, i'm going to make a rquest to the server, you need anything?"
  • The other modules can now optionally file a request at the proxy
  • Then the actual "combined" request is fired to the server and result is again split up and given to the modules that requested it

So my questions are:

  1. Is there a standard way in Struts2 of how to do something like this?
  2. Is there a standard "public" way of calling another action manually and getting its results from the value Stack?
like image 957
Chris Avatar asked Nov 04 '22 00:11

Chris


1 Answers

This can be achieved by using "redirectAction" in result type. following code is the example for same. you have to configure action tag in struts XML according to your requirement of using nested Actions.

     <action name="userHomeAction" class="com.etp.connect.struts.action.UserHomeAction">
        <result type="redirectAction" name="SUCCESS_EDIT">
            <param name="actionName">getUserEditData</param>
            <param name="selectedUser">${selectedUser}</param>        
        </result>
        <result name="error">/jsp/userMgmt/Users_Home.jsp</result>
        <result name="login">/jsp/loginMgmt/Login.jsp</result>
    </action>
like image 135
Mehul Avatar answered Nov 28 '22 05:11

Mehul