Performing several actions one after another

I need a way to do multiple struts with a single request. The goal is to minimize the need for a server request. Therefore, I need something like "MultiAction", which receives a list of actions as parameters that it should perform, and then returns a "combined" result of these actions.

For instance:

  • The client is divided into many modules
  • One module should receive information from the server
  • The client processing this request has a proxy server.
  • This proxy now goes and says: "Hey, other modules, I'm going to do rquest on the server, do you need anything?"
  • Other modules can now additionally request a proxy file
  • Then the actual "combined" request is launched on the server, and the result is again split up and provided to the modules that requested it.

So my questions are:

  • Is there a standard way in Struts2 how to do something like this?
  • Is there a standard β€œpublic” way to call another action manually and get its results from the Stack value?
+5
source share
3 answers

This can be achieved using "redirectAction" in the result type. The following code is an example for this. you need to customize the action tag in struts XML to suit 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>
+2
source

s > 1 > 2 > Struts 2 Chain Result. - , . Interceptor , . , .

    <package name="public" extends="struts-default">
            <action name="createUserAccount"
                class="net.onlineSolution.CreateAccountAction">
                <result name="success" type="chain">login</result>
            </action>
            <action name="login"
                class="net.onlineSolution.LoginAction">
                <result name="success" type="chain">showDashboard</result>
            </action>
            <action name="showDashboard"
                class="net.onlineSolution.DashboardAction">
                <result name="success">/WEB-INF/jsp/dashboard.jsp</result>
            </action>
    </package>

: createUserAccount, login showDashboard. , , . , , createAccount. .

0

Well. This is very possible using the simple struts result type. To process several actions in one action, you can use the result property. Using these few steps, you can also pass n the number of parameters using the struts.xml property . The following code sample is for your reference: - <result name="success" type="redirectAction"></result> <param>

<result name="success" type="redirectAction">
     <param name="actionName">[.. you can write another action here ..]</param>
     <param name="[.. parameter name ..]">${.. parameter name ..}</param>
</result>
0
source

All Articles