You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Andre Selton <as...@yahoo.com> on 2003/03/19 13:40:16 UTC

Re[2]: How to use forward parameters ? Newbie

Hello Nicolas,

Tuesday, March 18, 2003, 9:33:51 AM, you wrote:
NDL> <set-property> is used when using a class that
extends ActionForward
NDL> (using className="") to set it's properties,
without having to extend
NDL> ActionServlet or change struts DTD.

  I am undestanding this now.

NDL> If you want to pass some datas to another action,
you can

  I have some pages on my system who can be called
from different
places. The local from where they was called will
determine the next
page to show.
  One example of this is the login action. It can be
called when the
user press the "login" link on a application page. On
this case after
the login is finished the next page show is the main
site page.
  But when it is called to authenticate the user who
is doing the
checkout the page to be show is another.
  What is the best practice to handle this type of
problem ?
  
NDL> - use servlet context to put a javaBean

  Can you show how to do this ? Some small code is ok.
  
NDL> - add (or overwrite) a request parameters by
creating a new
NDL> ActionForward with path
"newAction.do?newParam=value"

  I was able to implement what I want using this idea.
But the code is
very bad. I really hope there are a better option.

  Andre S.

>>   Hello,
>>
>>   I can use set-property on a action forward like
this :
>>
>>     <action type="FooAction" path="/fooAction">
>>       <forward name="success" path="/newAction.do">
>>         <set-property value="barbar" property="bar"
/>
>>       </forward>
>>     </action>
>>
>>   This redirect me to another action.
>>   How can I get the value of set-property on the
>> newAction ?
>>   I did not find this on the docs, if you can point
>> where I can found it is ok.

__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com

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


Re: Re[2]: How to use forward parameters ? Newbie

Posted by Nicolas De Loof <ni...@cgey.com>.
>   I have some pages on my system who can be called
> from different
> places. The local from where they was called will
> determine the next
> page to show.
>   One example of this is the login action. It can be
> called when the
> user press the "login" link on a application page. On
> this case after
> the login is finished the next page show is the main
> site page.
>   But when it is called to authenticate the user who
> is doing the
> checkout the page to be show is another.
>   What is the best practice to handle this type of
> problem ?
>

A simple way to do it :
you should define 2 actionMapping
first one for "login", second one for "checkout"
the two use your LoginAction class and forward to success
"success" = Menu.sjp on mapping 1
"success" = Other on mapping 2

A second way to do it:
add a hidden input on your form (let's call it "dispatch"). This is a
very common way to
have different behaviour from the same action.
then define 2 forwards :
"login" => Menu.jsp
"checkout" => Other.jsp
in LoginAction, use dispatch value to get successful ActionForward.


For such a case you don't need to "forward parameter" to another
action. Your action just need to know in which case it is used (using
2 mappings or based on a form input)

Nico.


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