You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Nicolas De Loof <ni...@cgey.com> on 2003/07/18 14:24:01 UTC

Re: actions best practice question

According to MVC pattern ,alway link to action, not to JSP. This way you controler always knows what the user is doing,
and you can add some logic if needed.

Using a request parameter to addapt action behaviour is a common Struts use (take a look at DispatchAction).

Nico.




> I have a login page with a link with "forgot password?" for users to
> retrieve the passwords to their email account in case they forgot it.
> It's pretty trivial but still using struts what is the best practice?
>
> Should the link inside the login page point to the ForgotPassword.jsp or
> to a ForgotPassword.do action?
>
> Currently I used a ForgotPassword.do, and in the action I check if
> there's an 'action' parameter with the value of 'send'. If the 'action'
> parameter does not exist then I locally forward to the
> ForgotPassword.jsp using struts-config.xml local forwards configuration.
> If it does exist and equals to 'send' then I perform the actual
> operation of going to the EJB layer and do what is necessary to do.
> Is this the way to do it, or am I missing the point here?
>
> Any comment would be greatly appreciated here,
> Thanks,
> Erez
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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


RE: actions best practice question

Posted by Erez Efrati <er...@netmedia.net.il>.
Thanks again Nico.

-----Original Message-----
From: Nicolas De Loof [mailto:nicolas.deloof@cgey.com] 
Sent: Friday, July 18, 2003 3:06 PM
To: Struts Users Mailing List
Subject: Re: actions best practice question

I use a Forward action-mapping :

    <action path="/newUser/init" 
            forward="/newUser.jsp" />

You can use ForwardAction instead :

    <action path="/newUser/init" 
            type="org.apache.struts.actions.ForwardAction"
            parameter="/newUser.jsp"/>

I think ForwardAction is prefered when you want this request to use a
formbean and have validation.

Nico.


> Nico, thanks a lot for the prompt answers.
>  
> Do you use for that the org.apache.struts.actions.ForwardAction ?
> 
> Erez
> 
> 
> 
> -----Original Message-----
> From: Nicolas De Loof [mailto:nicolas.deloof@cgey.com] 
> Sent: Friday, July 18, 2003 2:48 PM
> To: Struts Users Mailing List
> Subject: Re: actions best practice question
> 
> I use to set a specialized action-mapping for such "init" request,
that
> is a simple forward (no Action class needed)
> 
> /newUser/init.do  => forward to newUser.jsp
> 
> /newUser/register.do => RegiterUserAction => welcome.jsp^
> 
> if needed, forward to newUser.jsp can be easily changed by a full
Action
> class (to init a form-bean with some default
> values for example)
> 
> Nico.
> 
> 
> 
> 
> > Nico,
> >
> > I agree with that, and that is basically how I did. But I was
> wondering
> > for the first time the action is called, basically just for
displaying
> > the page letting the user type in the fields values and click
submit,
> > what action do you use, if any? Cause, it's only the next time the
> > action is called that the action is going to do real action.
> >
> > Erez
> >
> > -----Original Message-----
> > From: Nicolas De Loof [mailto:nicolas.deloof@cgey.com]
> > Sent: Friday, July 18, 2003 2:24 PM
> > To: Struts Users Mailing List
> > Subject: Re: actions best practice question
> >
> > According to MVC pattern ,alway link to action, not to JSP. This way
> you
> > controler always knows what the user is doing,
> > and you can add some logic if needed.
> >
> > Using a request parameter to addapt action behaviour is a common
> Struts
> > use (take a look at DispatchAction).
> >
> > Nico.
> >
> >
> >
> >
> > > I have a login page with a link with "forgot password?" for users
to
> > > retrieve the passwords to their email account in case they forgot
> it.
> > > It's pretty trivial but still using struts what is the best
> practice?
> > >
> > > Should the link inside the login page point to the
> ForgotPassword.jsp
> > or
> > > to a ForgotPassword.do action?
> > >
> > > Currently I used a ForgotPassword.do, and in the action I check if
> > > there's an 'action' parameter with the value of 'send'. If the
> > 'action'
> > > parameter does not exist then I locally forward to the
> > > ForgotPassword.jsp using struts-config.xml local forwards
> > configuration.
> > > If it does exist and equals to 'send' then I perform the actual
> > > operation of going to the EJB layer and do what is necessary to
do.
> > > Is this the way to do it, or am I missing the point here?
> > >
> > > Any comment would be greatly appreciated here,
> > > Thanks,
> > > Erez
> > >
> > >
> > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail:
struts-user-help@jakarta.apache.org
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org

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




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


Re: actions best practice question

Posted by Nicolas De Loof <ni...@cgey.com>.
I use a Forward action-mapping :

    <action path="/newUser/init" 
            forward="/newUser.jsp" />

You can use ForwardAction instead :

    <action path="/newUser/init" 
            type="org.apache.struts.actions.ForwardAction"
            parameter="/newUser.jsp"/>

I think ForwardAction is prefered when you want this request to use a formbean and have validation.

Nico.


> Nico, thanks a lot for the prompt answers.
>  
> Do you use for that the org.apache.struts.actions.ForwardAction ?
> 
> Erez
> 
> 
> 
> -----Original Message-----
> From: Nicolas De Loof [mailto:nicolas.deloof@cgey.com] 
> Sent: Friday, July 18, 2003 2:48 PM
> To: Struts Users Mailing List
> Subject: Re: actions best practice question
> 
> I use to set a specialized action-mapping for such "init" request, that
> is a simple forward (no Action class needed)
> 
> /newUser/init.do  => forward to newUser.jsp
> 
> /newUser/register.do => RegiterUserAction => welcome.jsp^
> 
> if needed, forward to newUser.jsp can be easily changed by a full Action
> class (to init a form-bean with some default
> values for example)
> 
> Nico.
> 
> 
> 
> 
> > Nico,
> >
> > I agree with that, and that is basically how I did. But I was
> wondering
> > for the first time the action is called, basically just for displaying
> > the page letting the user type in the fields values and click submit,
> > what action do you use, if any? Cause, it's only the next time the
> > action is called that the action is going to do real action.
> >
> > Erez
> >
> > -----Original Message-----
> > From: Nicolas De Loof [mailto:nicolas.deloof@cgey.com]
> > Sent: Friday, July 18, 2003 2:24 PM
> > To: Struts Users Mailing List
> > Subject: Re: actions best practice question
> >
> > According to MVC pattern ,alway link to action, not to JSP. This way
> you
> > controler always knows what the user is doing,
> > and you can add some logic if needed.
> >
> > Using a request parameter to addapt action behaviour is a common
> Struts
> > use (take a look at DispatchAction).
> >
> > Nico.
> >
> >
> >
> >
> > > I have a login page with a link with "forgot password?" for users to
> > > retrieve the passwords to their email account in case they forgot
> it.
> > > It's pretty trivial but still using struts what is the best
> practice?
> > >
> > > Should the link inside the login page point to the
> ForgotPassword.jsp
> > or
> > > to a ForgotPassword.do action?
> > >
> > > Currently I used a ForgotPassword.do, and in the action I check if
> > > there's an 'action' parameter with the value of 'send'. If the
> > 'action'
> > > parameter does not exist then I locally forward to the
> > > ForgotPassword.jsp using struts-config.xml local forwards
> > configuration.
> > > If it does exist and equals to 'send' then I perform the actual
> > > operation of going to the EJB layer and do what is necessary to do.
> > > Is this the way to do it, or am I missing the point here?
> > >
> > > Any comment would be greatly appreciated here,
> > > Thanks,
> > > Erez
> > >
> > >
> > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org

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


RE: actions best practice question

Posted by Erez Efrati <er...@netmedia.net.il>.
Nico, thanks a lot for the prompt answers.
 
Do you use for that the org.apache.struts.actions.ForwardAction ?

Erez



-----Original Message-----
From: Nicolas De Loof [mailto:nicolas.deloof@cgey.com] 
Sent: Friday, July 18, 2003 2:48 PM
To: Struts Users Mailing List
Subject: Re: actions best practice question

I use to set a specialized action-mapping for such "init" request, that
is a simple forward (no Action class needed)

/newUser/init.do  => forward to newUser.jsp

/newUser/register.do => RegiterUserAction => welcome.jsp^

if needed, forward to newUser.jsp can be easily changed by a full Action
class (to init a form-bean with some default
values for example)

Nico.




> Nico,
>
> I agree with that, and that is basically how I did. But I was
wondering
> for the first time the action is called, basically just for displaying
> the page letting the user type in the fields values and click submit,
> what action do you use, if any? Cause, it's only the next time the
> action is called that the action is going to do real action.
>
> Erez
>
> -----Original Message-----
> From: Nicolas De Loof [mailto:nicolas.deloof@cgey.com]
> Sent: Friday, July 18, 2003 2:24 PM
> To: Struts Users Mailing List
> Subject: Re: actions best practice question
>
> According to MVC pattern ,alway link to action, not to JSP. This way
you
> controler always knows what the user is doing,
> and you can add some logic if needed.
>
> Using a request parameter to addapt action behaviour is a common
Struts
> use (take a look at DispatchAction).
>
> Nico.
>
>
>
>
> > I have a login page with a link with "forgot password?" for users to
> > retrieve the passwords to their email account in case they forgot
it.
> > It's pretty trivial but still using struts what is the best
practice?
> >
> > Should the link inside the login page point to the
ForgotPassword.jsp
> or
> > to a ForgotPassword.do action?
> >
> > Currently I used a ForgotPassword.do, and in the action I check if
> > there's an 'action' parameter with the value of 'send'. If the
> 'action'
> > parameter does not exist then I locally forward to the
> > ForgotPassword.jsp using struts-config.xml local forwards
> configuration.
> > If it does exist and equals to 'send' then I perform the actual
> > operation of going to the EJB layer and do what is necessary to do.
> > Is this the way to do it, or am I missing the point here?
> >
> > Any comment would be greatly appreciated here,
> > Thanks,
> > Erez
> >
> >
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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




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


Re: actions best practice question

Posted by Nicolas De Loof <ni...@cgey.com>.
I use to set a specialized action-mapping for such "init" request, that is a simple forward (no Action class needed)

/newUser/init.do  => forward to newUser.jsp

/newUser/register.do => RegiterUserAction => welcome.jsp^

if needed, forward to newUser.jsp can be easily changed by a full Action class (to init a form-bean with some default
values for example)

Nico.




> Nico,
>
> I agree with that, and that is basically how I did. But I was wondering
> for the first time the action is called, basically just for displaying
> the page letting the user type in the fields values and click submit,
> what action do you use, if any? Cause, it's only the next time the
> action is called that the action is going to do real action.
>
> Erez
>
> -----Original Message-----
> From: Nicolas De Loof [mailto:nicolas.deloof@cgey.com]
> Sent: Friday, July 18, 2003 2:24 PM
> To: Struts Users Mailing List
> Subject: Re: actions best practice question
>
> According to MVC pattern ,alway link to action, not to JSP. This way you
> controler always knows what the user is doing,
> and you can add some logic if needed.
>
> Using a request parameter to addapt action behaviour is a common Struts
> use (take a look at DispatchAction).
>
> Nico.
>
>
>
>
> > I have a login page with a link with "forgot password?" for users to
> > retrieve the passwords to their email account in case they forgot it.
> > It's pretty trivial but still using struts what is the best practice?
> >
> > Should the link inside the login page point to the ForgotPassword.jsp
> or
> > to a ForgotPassword.do action?
> >
> > Currently I used a ForgotPassword.do, and in the action I check if
> > there's an 'action' parameter with the value of 'send'. If the
> 'action'
> > parameter does not exist then I locally forward to the
> > ForgotPassword.jsp using struts-config.xml local forwards
> configuration.
> > If it does exist and equals to 'send' then I perform the actual
> > operation of going to the EJB layer and do what is necessary to do.
> > Is this the way to do it, or am I missing the point here?
> >
> > Any comment would be greatly appreciated here,
> > Thanks,
> > Erez
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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


RE: actions best practice question

Posted by Erez Efrati <er...@netmedia.net.il>.
Nico, 

I agree with that, and that is basically how I did. But I was wondering
for the first time the action is called, basically just for displaying
the page letting the user type in the fields values and click submit,
what action do you use, if any? Cause, it's only the next time the
action is called that the action is going to do real action.

Erez

-----Original Message-----
From: Nicolas De Loof [mailto:nicolas.deloof@cgey.com] 
Sent: Friday, July 18, 2003 2:24 PM
To: Struts Users Mailing List
Subject: Re: actions best practice question

According to MVC pattern ,alway link to action, not to JSP. This way you
controler always knows what the user is doing,
and you can add some logic if needed.

Using a request parameter to addapt action behaviour is a common Struts
use (take a look at DispatchAction).

Nico.




> I have a login page with a link with "forgot password?" for users to
> retrieve the passwords to their email account in case they forgot it.
> It's pretty trivial but still using struts what is the best practice?
>
> Should the link inside the login page point to the ForgotPassword.jsp
or
> to a ForgotPassword.do action?
>
> Currently I used a ForgotPassword.do, and in the action I check if
> there's an 'action' parameter with the value of 'send'. If the
'action'
> parameter does not exist then I locally forward to the
> ForgotPassword.jsp using struts-config.xml local forwards
configuration.
> If it does exist and equals to 'send' then I perform the actual
> operation of going to the EJB layer and do what is necessary to do.
> Is this the way to do it, or am I missing the point here?
>
> Any comment would be greatly appreciated here,
> Thanks,
> Erez
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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



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