You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Van Riper, Mike" <mv...@verisign.com> on 2003/04/01 03:07:09 UTC
RE: Right way to extends Action
> -----Original Message-----
> From: Xavier Saint-Denis [mailto:stdenis2@free.fr]
> Sent: Monday, March 31, 2003 4:21 AM
> To: Struts Users Mailing List
> Subject: Re: Right way to extends Action
>
>
> Hi,
> In our application we use a similar concept :
>
> - we have a class like this :
> public abstract class BaseAction extends Action
What about DispatchAction and LookupDispatchAction? Anyone have a good
solution for reuse of common action logic across these multiple action base
classes provided by Struts?
>
> In this class :
>
> - we added some usefull field like a logger an a pointer to a
> singleton that
> retains application's data
> protected Log log = LogFactory.getLog(this.getClass());
> protected static final Infos infos = Infos.getInstance();
>
> - We change the modifier of the execute Method so as to be
> sure nobody use
> it directly:
> public final ActionForward execute(ActionMapping
> _mapping, ActionForm
> _form, HttpServletRequest _req, HttpServletResponse _res)
> throws Exception {
>
> - In this method we check the user session and log in information
> - At the end of this method we call
> return executeAction(_mapping, _form, _req, _res);
>
> - This method "executeAction" is defined as this :
> public abstract ActionForward executeAction(ActionMapping
> _mapping,
> ActionForm _form, HttpServletRequest _req,
> HttpServletResponse _res) throws
> Exception;
>
> - So when we create a new action, we extend BaseAction and
> implement the
> abstract method executeAction
> This way, we have automatic user login check, and a logger at
> disposition.
>
> regards,
>
> Xavier
>
> ----- Original Message -----
> From: "niksa_os" <ni...@hotmail.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Monday, March 31, 2003 1:45 PM
> Subject: Right way to extends Action
>
>
> I want all my Actions to extend BaseAction.
>
> In BaseAction I want to check user session and to put some
> data in it, if
> that data doesn't exist.
>
> Is it good way:
>
> public class SomeAction extends BaseAction {
> public ActionForward execute( ActionMapping mapping,
> ActionForm form,
> HttpServletRequest request,
> HttpServletResponse response ) {
> super.execute( mapping,form, request, response);
> OK, proceed ...........
>
>
> public class BaseAction extends BaseAction {
> public ActionForward execute( ActionMapping mapping,
> ActionForm form,
> HttpServletRequest request,
> HttpServletResponse response ) {
> if (userSession is wrong) {
> -try -- put data in session
> -catch -- return mapping.findForward("wrongSession");}
> else return null; //everything is OK
>
> What you think about this way and is there better way to
> extend Action?
>
> Thanks.
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Right way to extends Action
Posted by Navjot Singh <na...@net4india.net>.
thanks buddy, got the idea now. My problem is solved.
-navjot
The programming world now seems to be all about writing wrapper codes ;-)
----- Original Message -----
From: "V. Cekvenich" <vC...@baseBeans.com>
To: <st...@jakarta.apache.org>
Sent: Tuesday, April 01, 2003 7:27 AM
Subject: Re: Right way to extends Action
|
| >
| >
| > What about DispatchAction and LookupDispatchAction? Anyone have a good
| > solution for reuse of common action logic across these multiple action
base
| > classes provided by Struts?
| >
|
|
| I wrote my own dispatch:
|
|
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/basicportal/bP/WEB-INF/src/wa
r/org/apache/scaffoldingLib/base/BaseAct.java
|
| .V
|
|
|
|
| ---------------------------------------------------------------------
| 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: Right way to extends Action
Posted by "V. Cekvenich" <vC...@baseBeans.com>.
>
>
> What about DispatchAction and LookupDispatchAction? Anyone have a good
> solution for reuse of common action logic across these multiple action base
> classes provided by Struts?
>
I wrote my own dispatch:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/basicportal/bP/WEB-INF/src/war/org/apache/scaffoldingLib/base/BaseAct.java
.V
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Right way to extends Action
Posted by Igor Shabalov <ig...@exadel.com>.
In general I like an idea to assembly application from set of pre-defined
actions with parameters. It is about reuse of actual action
“implementations” within application.
Best,
Igor.
On Mon, 31 Mar 2003 17:07:09 -0800, Van Riper, Mike
<mv...@verisign.com> wrote:
>> -----Original Message-----
>> From: Xavier Saint-Denis [mailto:stdenis2@free.fr]
>> Sent: Monday, March 31, 2003 4:21 AM
>> To: Struts Users Mailing List
>> Subject: Re: Right way to extends Action
>>
>>
>> Hi,
>> In our application we use a similar concept :
>>
>> - we have a class like this :
>> public abstract class BaseAction extends Action
>
> What about DispatchAction and LookupDispatchAction? Anyone have a good
> solution for reuse of common action logic across these multiple action
> base
> classes provided by Struts?
>
>>
>> In this class :
>>
>> - we added some usefull field like a logger an a pointer to a singleton
>> that
>> retains application's data
>> protected Log log = LogFactory.getLog(this.getClass());
>> protected static final Infos infos = Infos.getInstance();
>>
>> - We change the modifier of the execute Method so as to be sure nobody
>> use
>> it directly:
>> public final ActionForward execute(ActionMapping _mapping, ActionForm
>> _form, HttpServletRequest _req, HttpServletResponse _res) throws
>> Exception {
>>
>> - In this method we check the user session and log in information
>> - At the end of this method we call
>> return executeAction(_mapping, _form, _req, _res);
>>
>> - This method "executeAction" is defined as this :
>> public abstract ActionForward executeAction(ActionMapping _mapping,
>> ActionForm _form, HttpServletRequest _req, HttpServletResponse _res)
>> throws
>> Exception;
>>
>> - So when we create a new action, we extend BaseAction and implement the
>> abstract method executeAction
>> This way, we have automatic user login check, and a logger at
>> disposition.
>>
>> regards,
>>
>> Xavier
>>
>> ----- Original Message -----
>> From: "niksa_os" <ni...@hotmail.com>
>> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
>> Sent: Monday, March 31, 2003 1:45 PM
>> Subject: Right way to extends Action
>>
>>
>> I want all my Actions to extend BaseAction.
>>
>> In BaseAction I want to check user session and to put some data in it,
>> if
>> that data doesn't exist.
>>
>> Is it good way:
>>
>> public class SomeAction extends BaseAction {
>> public ActionForward execute( ActionMapping mapping,
>> ActionForm form,
>> HttpServletRequest request,
>> HttpServletResponse response ) {
>> super.execute( mapping,form, request, response);
>> OK, proceed ...........
>>
>>
>> public class BaseAction extends BaseAction {
>> public ActionForward execute( ActionMapping mapping,
>> ActionForm form,
>> HttpServletRequest request,
>> HttpServletResponse response ) {
>> if (userSession is wrong) {
>> -try -- put data in session
>> -catch -- return mapping.findForward("wrongSession");}
>> else return null; //everything is OK
>>
>> What you think about this way and is there better way to extend Action?
>>
>> Thanks.
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
--
Igor Shabalov
Director of Engineering
Exadel Inc.
http://www.exadel.com
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org