You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Oleg V Alexeev <oa...@apache.org> on 2001/07/27 21:52:44 UTC

Re[2]: Passing parameters when chaining actions

Hello Fabien,

Friday, July 27, 2001, 11:29:06 PM, you wrote:

FM> Hello Oleg,

FM> Thanks for your help. 

>> Can you save values in request or in session context? 

FM> I was trying to avoid using the session context and using
FM> the request, so that I have less clean-up to do:). I could 
FM> use either one if this is the best way.

FM> If I place my parameter as request attribute, will the
FM> form population algorithm look in both the request parameters
FM> and attributes?

Form population algorithm looks for parameters only,

>> If no, then you can build query string, add it to the path 
>> in forward and forward to the nested action. All values 
>> will be automatically passed to the action's form.

FM> That's a very good idea; I actually didn't know I could
FM> do that.

Find or create forward, take path from it, create Map with parameters
as for html:link tag, pass this map to the RequestUtils.computeURL()
method to compute URL and add computed URL prepended with '?' sign to
the path for the forward. Return it. Thats all.

FM> Which solution do you think is best?

I don't like both... 8) But if you use your nested action twice or
more in your application and not as nested action only (in one
situation as nested in another - as standart action) then the best way
is to pass values via query string.
If you use this action as nested only then solution with request
attributes gets you less overhead against query string.


FM> Thanks,

FM> -Fabien

FM> ---------------------------------------------      
FM> Fabien Modoux,
FM> Voicemate - http://www.voicemate.com

FM> -----Original Message-----
FM> From: Oleg V Alexeev [mailto:oalexeev@apache.org]
FM> Sent: Friday, July 27, 2001 2:34 PM
FM> To: struts-user@jakarta.apache.org
FM> Subject: Re: Passing parameters when chaining actions


FM> Hello Fabien,

FM> Friday, July 27, 2001, 8:02:28 PM, you wrote:

FM>> I would like to have an action pass parameters
FM>> to another actions using a forward action mapping.
FM>> The second action is configured with a form in
FM>> the request scope:

FM>>     <form-bean      name="action2Form"
FM>>                     type="Action2Form"/>

FM>>     <action    path="/my_action1.do"
FM>>                type="Action1">
FM>>       <forward name="call_action2"         path="/my_action2.do"/>
FM>>     </action>

FM>>     <action    path="/my_action2.do"
FM>>                type="Action2"
FM>>                name="action2Form"
FM>>                scope="request">
FM>>       <!-- forwards -->
FM>>     </action>

FM>> I tried to have the first action instantiate
FM>> the form, populate it, and set it as a request 
FM>> attribute, under the name of the form defined 
FM>> in my struts-config file (action2Form). However,
FM>> when I cast the form in action2 to the action2Form,
FM>> all the fields are null? Should this work, or
FM>> shall I manually look in the request for the
FM>> form? Is there a better way to do that?

FM> Can you save values in request or in session context? If no, then you
FM> can build query string, add it to the path in forward and forward to
FM> the nested action. All values will be automatically passed to the
FM> action's form.




-- 
Best regards,
 Oleg                            mailto:oalexeev@apache.org



RE: Re[2]: Passing parameters when chaining actions

Posted by Fabien Modoux <fa...@voicemate.com>.
Thank you very much, Oleg.

As I am planning to use the second action from 
both nested calls and direct calls, I think I
will go with the query string option.

Regards,

-Fabien

---------------------------------------------      
Fabien Modoux,
Voicemate - http://www.voicemate.com

-----Original Message-----
From: Oleg V Alexeev [mailto:oalexeev@apache.org]
Sent: Friday, July 27, 2001 3:53 PM
To: struts-user@jakarta.apache.org
Subject: Re[2]: Passing parameters when chaining actions


Hello Fabien,

Friday, July 27, 2001, 11:29:06 PM, you wrote:

FM> Hello Oleg,

FM> Thanks for your help. 

>> Can you save values in request or in session context? 

FM> I was trying to avoid using the session context and using
FM> the request, so that I have less clean-up to do:). I could 
FM> use either one if this is the best way.

FM> If I place my parameter as request attribute, will the
FM> form population algorithm look in both the request parameters
FM> and attributes?

Form population algorithm looks for parameters only,

>> If no, then you can build query string, add it to the path 
>> in forward and forward to the nested action. All values 
>> will be automatically passed to the action's form.

FM> That's a very good idea; I actually didn't know I could
FM> do that.

Find or create forward, take path from it, create Map with parameters
as for html:link tag, pass this map to the RequestUtils.computeURL()
method to compute URL and add computed URL prepended with '?' sign to
the path for the forward. Return it. Thats all.

FM> Which solution do you think is best?

I don't like both... 8) But if you use your nested action twice or
more in your application and not as nested action only (in one
situation as nested in another - as standart action) then the best way
is to pass values via query string.
If you use this action as nested only then solution with request
attributes gets you less overhead against query string.


FM> Thanks,

FM> -Fabien

FM> ---------------------------------------------      
FM> Fabien Modoux,
FM> Voicemate - http://www.voicemate.com

FM> -----Original Message-----
FM> From: Oleg V Alexeev [mailto:oalexeev@apache.org]
FM> Sent: Friday, July 27, 2001 2:34 PM
FM> To: struts-user@jakarta.apache.org
FM> Subject: Re: Passing parameters when chaining actions


FM> Hello Fabien,

FM> Friday, July 27, 2001, 8:02:28 PM, you wrote:

FM>> I would like to have an action pass parameters
FM>> to another actions using a forward action mapping.
FM>> The second action is configured with a form in
FM>> the request scope:

FM>>     <form-bean      name="action2Form"
FM>>                     type="Action2Form"/>

FM>>     <action    path="/my_action1.do"
FM>>                type="Action1">
FM>>       <forward name="call_action2"         path="/my_action2.do"/>
FM>>     </action>

FM>>     <action    path="/my_action2.do"
FM>>                type="Action2"
FM>>                name="action2Form"
FM>>                scope="request">
FM>>       <!-- forwards -->
FM>>     </action>

FM>> I tried to have the first action instantiate
FM>> the form, populate it, and set it as a request 
FM>> attribute, under the name of the form defined 
FM>> in my struts-config file (action2Form). However,
FM>> when I cast the form in action2 to the action2Form,
FM>> all the fields are null? Should this work, or
FM>> shall I manually look in the request for the
FM>> form? Is there a better way to do that?

FM> Can you save values in request or in session context? If no, then you
FM> can build query string, add it to the path in forward and forward to
FM> the nested action. All values will be automatically passed to the
FM> action's form.




-- 
Best regards,
 Oleg                            mailto:oalexeev@apache.org