You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Dao Cong Hung (FSU17.BU68)" <Hu...@fsoft.com.vn.INVALID> on 2017/03/27 07:16:13 UTC

Pass a parameter from action to other action with type result "chain"

Dear all,
I have a problem. When I  pass a parameter from action to other action , why it is not support?

Thanks & Best Regards
HungDC


RE: Pass a parameter from action to other action with type result "chain"

Posted by "Dao Cong Hung (FSU17.BU68)" <Hu...@fsoft.com.vn.INVALID>.
Thanks you very much. I know how to do it!

-----Original Message-----
From: Lukasz Lenart [mailto:lukaszlenart@apache.org] 
Sent: Dienschdàà 28 März 2017 16:57
To: Struts Users Mailing List
Subject: Re: Pass a parameter from action to other action with type result "chain"

2017-03-28 10:48 GMT+02:00 Dao Cong Hung (FSU17.BU68)
<Hu...@fsoft.com.vn.invalid>:
> Thanks you, So if I convert struts1 to Struts2 in file config.xml.
> <forward name="error"      path="/ action2.do?name=close " />  it keep request at the action2
> So with struts2 type result  the same forward except "chain"

Nope, there is no "forward to action" result in Struts2, the closest approach is to use "chain" but it isn't recommended. Since you're migrating the project maybe it would be a good idea to rethink some patterns, which worked well in Struts1 but not in Struts2 - Struts2 is a totally different framework and uses different patterns.


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Pass a parameter from action to other action with type result "chain"

Posted by Lukasz Lenart <lu...@apache.org>.
2017-03-28 10:48 GMT+02:00 Dao Cong Hung (FSU17.BU68)
<Hu...@fsoft.com.vn.invalid>:
> Thanks you, So if I convert struts1 to Struts2 in file config.xml.
> <forward name="error"      path="/ action2.do?name=close " />  it keep request at the action2
> So with struts2 type result  the same forward except "chain"

Nope, there is no "forward to action" result in Struts2, the closest
approach is to use "chain" but it isn't recommended. Since you're
migrating the project maybe it would be a good idea to rethink some
patterns, which worked well in Struts1 but not in Struts2 - Struts2 is
a totally different framework and uses different patterns.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Pass a parameter from action to other action with type result "chain"

Posted by "Dao Cong Hung (FSU17.BU68)" <Hu...@fsoft.com.vn.INVALID>.
Thanks you, So if I convert struts1 to Struts2 in file config.xml. 
<forward name="error"      path="/ action2.do?name=close " />  it keep request at the action2
So with struts2 type result  the same forward except "chain"

-----Original Message-----
From: Lukasz Lenart [mailto:lukaszlenart@apache.org] 
Sent: Dienschdàà 28 März 2017 15:40
To: Struts Users Mailing List
Subject: Re: Pass a parameter from action to other action with type result "chain"

2017-03-28 10:17 GMT+02:00 Dao Cong Hung (FSU17.BU68)
<Hu...@fsoft.com.vn.invalid>:
> I don't understand what are you meaning.You can suggest me .Because I want to keep request of action1 in action2 by way to use type result "chain"

Using action chaining isn't recommended, instead it's better to re-think why do you want to do it and use some other result type:
https://struts.apache.org/docs/action-chaining.html

but if you want to do it you must define exactly the same getters/setters in both actions to pass static params, and you must define this on action level not on result level, see the example:
https://github.com/apache/struts-examples/tree/master/action-chaining


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Pass a parameter from action to other action with type result "chain"

Posted by Lukasz Lenart <lu...@apache.org>.
2017-03-28 10:17 GMT+02:00 Dao Cong Hung (FSU17.BU68)
<Hu...@fsoft.com.vn.invalid>:
> I don't understand what are you meaning.You can suggest me .Because I want to keep request of action1 in action2 by way to use type result "chain"

Using action chaining isn't recommended, instead it's better to
re-think why do you want to do it and use some other result type:
https://struts.apache.org/docs/action-chaining.html

but if you want to do it you must define exactly the same
getters/setters in both actions to pass static params, and you must
define this on action level not on result level, see the example:
https://github.com/apache/struts-examples/tree/master/action-chaining


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Pass a parameter from action to other action with type result "chain"

Posted by "Dao Cong Hung (FSU17.BU68)" <Hu...@fsoft.com.vn.INVALID>.
I don't understand what are you meaning.You can suggest me .Because I want to keep request of action1 in action2 by way to use type result "chain"
> -------------------------I convert struts1 to 
> struts2-----------------------------------
> -------------------------Struts1: 
> ----------------------------------------
> <action path="action1 "
>                 type="jp.co.fujixerox.eappli.printapp.struts.PostLauncherAction1">
>         <forward name="error"      path="/ action2.do?name=close " />
>     </action>
> <action path="action2 "
>                 type="jp.co.fujixerox.eappli.printapp.struts.PostLauncherAction2">
>         <forward   name="success"    path">/jsp/showResult/success.jsp " />
>     </action>
> =>So at controller of action2 in class PostLauncherAction2, I use 
> request.getParameters("name")=close;
> ------------------------------Struts2---------------------------------
> ------------
> <action name="action1"
>                     class="jp.co.fujixerox.eappli.printapp.struts.PostLauncherAction1">
>                          <result name="error" type="chain">
>                                  <param name="actionName">action2</param>
>                                  <param name="name">close</param>
>                         </result>
>  </action>
>  <action name="action2"
>                          class="jp.co.fujixerox.eappli.printapp.struts.PostLauncherAction2">
>                         <result
>  name="success">/jsp/showResult/success.jsp</result>
>  </action>
>> So at controller of action2 in class PostLauncherAction2, I use 
>> request.getParameters("name")=null;


-----Original Message-----
From: Lukasz Lenart [mailto:lukaszlenart@apache.org] 
Sent: Dienschdàà 28 März 2017 15:08
To: Struts Users Mailing List
Subject: Re: Pass a parameter from action to other action with type result "chain"

2017-03-28 9:44 GMT+02:00 Dao Cong Hung (FSU17.BU68)
<Hu...@fsoft.com.vn.invalid>:
> But I want to keep request of action1 in action2 in order that in action2 I want get these attribute which is setAttribute in action1. If use actionRedirect it will new request!

So then, instead of redirecting use the same result as action2 is using


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Pass a parameter from action to other action with type result "chain"

Posted by Lukasz Lenart <lu...@apache.org>.
2017-03-28 9:44 GMT+02:00 Dao Cong Hung (FSU17.BU68)
<Hu...@fsoft.com.vn.invalid>:
> But I want to keep request of action1 in action2 in order that in action2 I want get these attribute which is setAttribute in action1. If use actionRedirect it will new request!

So then, instead of redirecting use the same result as action2 is using


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Pass a parameter from action to other action with type result "chain"

Posted by "Dao Cong Hung (FSU17.BU68)" <Hu...@fsoft.com.vn.INVALID>.
But I want to keep request of action1 in action2 in order that in action2 I want get these attribute which is setAttribute in action1. If use actionRedirect it will new request!

-----Original Message-----
From: Lukasz Lenart [mailto:lukaszlenart@apache.org] 
Sent: Dienschdàà 28 März 2017 14:41
To: Struts Users Mailing List
Subject: Re: Pass a parameter from action to other action with type result "chain"

2017-03-27 10:25 GMT+02:00 Dao Cong Hung (FSU17.BU68)
<Hu...@fsoft.com.vn.invalid>:
> -------------------------I convert struts1 to 
> struts2-----------------------------------
> -------------------------Struts1: 
> ----------------------------------------
> <action path="action1 "
>                 type="jp.co.fujixerox.eappli.printapp.struts.PostLauncherAction1">
>         <forward name="error"      path="/ action2.do?name=close " />
>     </action>
> <action path="action2 "
>                 type="jp.co.fujixerox.eappli.printapp.struts.PostLauncherAction2">
>         <forward   name="success"    path">/jsp/showResult/success.jsp " />
>     </action>
> =>So at controller of action2 in class PostLauncherAction2, I use 
> request.getParameters("name")=close;
> ------------------------------Struts2---------------------------------
> ------------
> <action name="action1"
>                     class="jp.co.fujixerox.eappli.printapp.struts.PostLauncherAction1">
>                          <result name="error" type="chain">
>                                  <param name="actionName">action2</param>
>                                  <param name="name">close</param>
>                         </result>
>  </action>
>  <action name="action2"
>                          class="jp.co.fujixerox.eappli.printapp.struts.PostLauncherAction2">
>                         <result
>  name="success">/jsp/showResult/success.jsp</result>
>  </action>
>> So at controller of action2 in class PostLauncherAction2, I use 
>> request.getParameters("name")=null;

I would use rather the "actionRedirect" result instead of the "chain" result https://struts.apache.org/docs/redirect-action-result.html


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

Re: Pass a parameter from action to other action with type result "chain"

Posted by Lukasz Lenart <lu...@apache.org>.
2017-03-27 10:25 GMT+02:00 Dao Cong Hung (FSU17.BU68)
<Hu...@fsoft.com.vn.invalid>:
> -------------------------I convert struts1 to struts2-----------------------------------
> -------------------------Struts1: ----------------------------------------
> <action path="action1 "
>                 type="jp.co.fujixerox.eappli.printapp.struts.PostLauncherAction1">
>         <forward name="error"      path="/ action2.do?name=close " />
>     </action>
> <action path="action2 "
>                 type="jp.co.fujixerox.eappli.printapp.struts.PostLauncherAction2">
>         <forward   name="success"    path">/jsp/showResult/success.jsp " />
>     </action>
> =>So at controller of action2 in class PostLauncherAction2, I use request.getParameters("name")=close;
> ------------------------------Struts2---------------------------------------------
> <action name="action1"
>                     class="jp.co.fujixerox.eappli.printapp.struts.PostLauncherAction1">
>                          <result name="error" type="chain">
>                                  <param name="actionName">action2</param>
>                                  <param name="name">close</param>
>                         </result>
>  </action>
>  <action name="action2"
>                          class="jp.co.fujixerox.eappli.printapp.struts.PostLauncherAction2">
>                         <result
>  name="success">/jsp/showResult/success.jsp</result>
>  </action>
>> So at controller of action2 in class PostLauncherAction2, I use request.getParameters("name")=null;

I would use rather the "actionRedirect" result instead of the "chain" result
https://struts.apache.org/docs/redirect-action-result.html


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Pass a parameter from action to other action with type result "chain"

Posted by "Dao Cong Hung (FSU17.BU68)" <Hu...@fsoft.com.vn.INVALID>.
-------------------------I convert struts1 to struts2-----------------------------------
-------------------------Struts1: ----------------------------------------
<action	path="action1 "
		type="jp.co.fujixerox.eappli.printapp.struts.PostLauncherAction1">
	<forward name="error"      path="/ action2.do?name=close " />
    </action>
<action	path="action2 "
		type="jp.co.fujixerox.eappli.printapp.struts.PostLauncherAction2">
	<forward   name="success"    path">/jsp/showResult/success.jsp " />
    </action>
=>So at controller of action2 in class PostLauncherAction2, I use request.getParameters("name")=close;
------------------------------Struts2---------------------------------------------
<action name="action1"
                    class="jp.co.fujixerox.eappli.printapp.struts.PostLauncherAction1">
                         <result name="error" type="chain">
                                 <param name="actionName">action2</param>
                                 <param name="name">close</param>
                        </result>
 </action>
 <action name="action2"
                         class="jp.co.fujixerox.eappli.printapp.struts.PostLauncherAction2">
                        <result 
 name="success">/jsp/showResult/success.jsp</result>
 </action>
> So at controller of action2 in class PostLauncherAction2, I use request.getParameters("name")=null;

-----Original Message-----
From: Lukasz Lenart [mailto:lukaszlenart@apache.org] 
Sent: Mondàà 27 März 2017 15:17
To: Struts Users Mailing List
Subject: Re: Pass a parameter from action to other action with type result "chain"

2017-03-27 9:31 GMT+02:00 Dao Cong Hung (FSU17.BU68)
<Hu...@fsoft.com.vn.invalid>:
> <action name="action1"
>                         class="jp.co.fujixerox.eappli.printapp.struts.PostLauncherAction">
>                         <result name="error" type="chain">
>                                 <param name="actionName">action2</param>
>                                 <param name="name">close</param>
>                         </result>
> </action>
> <action name="action2"
>                         class="jp.co.fujixerox.eappli.printapp.struts.PostLauncherAction">
>                         <result 
> name="success">/jsp/showResult/success.jsp</result>
> </action>
> So at controller of action2, I use request.getParameters("name")=null;

hm... but the "name" parameter from the "action1" isn't a request parameter, it will be applied only to the "action1".


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Pass a parameter from action to other action with type result "chain"

Posted by Lukasz Lenart <lu...@apache.org>.
2017-03-27 9:31 GMT+02:00 Dao Cong Hung (FSU17.BU68)
<Hu...@fsoft.com.vn.invalid>:
> <action name="action1"
>                         class="jp.co.fujixerox.eappli.printapp.struts.PostLauncherAction">
>                         <result name="error" type="chain">
>                                 <param name="actionName">action2</param>
>                                 <param name="name">close</param>
>                         </result>
> </action>
> <action name="action2"
>                         class="jp.co.fujixerox.eappli.printapp.struts.PostLauncherAction">
>                         <result name="success">/jsp/showResult/success.jsp</result>
> </action>
> So at controller of action2, I use request.getParameters("name")=null;

hm... but the "name" parameter from the "action1" isn't a request
parameter, it will be applied only to the "action1".


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Pass a parameter from action to other action with type result "chain"

Posted by "Dao Cong Hung (FSU17.BU68)" <Hu...@fsoft.com.vn.INVALID>.
<action name="action1"
			class="jp.co.fujixerox.eappli.printapp.struts.PostLauncherAction">
			<result name="error" type="chain">
				<param name="actionName">action2</param>
				<param name="name">close</param>
			</result>
</action>
<action name="action2"
			class="jp.co.fujixerox.eappli.printapp.struts.PostLauncherAction">
			<result name="success">/jsp/showResult/success.jsp</result>
</action>
So at controller of action2, I use request.getParameters("name")=null;
-----Original Message-----
From: Lukasz Lenart [mailto:lukaszlenart@apache.org] 
Sent: Mondàà 27 März 2017 14:25
To: Struts Users Mailing List
Subject: Re: Pass a parameter from action to other action with type result "chain"

2017-03-27 9:16 GMT+02:00 Dao Cong Hung (FSU17.BU68)
<Hu...@fsoft.com.vn.invalid>:
> Dear all,
> I have a problem. When I  pass a parameter from action to other action , why it is not support?

More details please.... Struts version, configuration, etc., hard to guess what problem do you have.


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

Re: Pass a parameter from action to other action with type result "chain"

Posted by Lukasz Lenart <lu...@apache.org>.
2017-03-27 9:16 GMT+02:00 Dao Cong Hung (FSU17.BU68)
<Hu...@fsoft.com.vn.invalid>:
> Dear all,
> I have a problem. When I  pass a parameter from action to other action , why it is not support?

More details please.... Struts version, configuration, etc., hard to
guess what problem do you have.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org