You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ashish Kulkarni <ku...@yahoo.com> on 2003/02/03 17:16:48 UTC
Override DispatchAction but keep the existing funcationallity
Hi,
I want to extend functions of dispatchAction class,
like i want a class which extends DispatchAction and
overrides the execute method, But keep all the
existing functions,
But if i override the execute method, then i will have
to code the same function available in origianl
DispatchAction, and add my extra functions, ( like cut
and paste the code) but then if in future
DispatchAction is modified i will need to modify my
class.
or have one class which will have all the functions of
DispatchAction , but also want to add more functions.
What i have done in MyActionClass is
public abstract class MyAction extends Action
{
public ActionForward execute(ActionMapping mapping,
ActionForm form,HttpServletRequest request,
HttpServletResponse response)
throws Exception
{
//common code for all action classes
CommonClass cc = new CommonClass();
// just sample method
cc.doValid();
return performTask(mapping, form, request,
response);
}
// this is the method which will be implemented by
each overriding class and add the necessary logic
protected abstract ActionForward
performTask(ActionMapping mapping,
ActionForm form, HttpServletRequest
request,
HttpServletResponse response)
throws Exception;
}
I have a CommonClass for doing all the common
function,
How can i do it DispatchAction
Ashish
=====
A$HI$H
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: Override DispatchAction but keep the existing funcationallity
Posted by Ashish Kulkarni <ku...@yahoo.com>.
Thanx Jerome,
I will try this out
Ashish
--- Jerome Jacobsen <je...@gentootech.com>
wrote:
> Correction. Your MyDispatchAction would not be
> abstract.
>
> > -----Original Message-----
> > From: Jerome Jacobsen
> [mailto:jerome.jacobsen@gentootech.com]
> > Sent: Monday, February 03, 2003 11:29 AM
> > To: Struts Users Mailing List
> > Subject: RE: Override DispatchAction but keep the
> existing
> > funcationallity
> >
> >
> > Your CommonCode solution is the way I went (I
> called mine
> > BaseActionHelper).
> >
> > Your subclass of DispatchAction would look
> something like this below.
> >
> > public abstract class MyDispatchAction extends
> DispatchAction
> > {
> > public ActionForward execute(ActionMapping
> mapping,
> > ActionForm form,HttpServletRequest request,
> > HttpServletResponse response)
> > throws Exception
> > {
> >
> > //common code for all action classes
> > CommonClass cc = new CommonClass();
> > // just sample method
> > cc.doValid();
> > return super.execute(mapping, form, request,
> > response);
> > }
> > }
> >
> > > -----Original Message-----
> > > From: Ashish Kulkarni
> [mailto:kulkarni_ash1312@yahoo.com]
> > > Sent: Monday, February 03, 2003 11:17 AM
> > > To: struts-user@jakarta.apache.org
> > > Subject: Override DispatchAction but keep the
> existing funcationallity
> > >
> > >
> > > Hi,
> > > I want to extend functions of dispatchAction
> class,
> > > like i want a class which extends DispatchAction
> and
> > > overrides the execute method, But keep all the
> > > existing functions,
> > > But if i override the execute method, then i
> will have
> > > to code the same function available in origianl
> > > DispatchAction, and add my extra functions, (
> like cut
> > > and paste the code) but then if in future
> > > DispatchAction is modified i will need to modify
> my
> > > class.
> > >
> > > or have one class which will have all the
> functions of
> > > DispatchAction , but also want to add more
> functions.
> > >
> > > What i have done in MyActionClass is
> > > public abstract class MyAction extends Action
> > > {
> > > public ActionForward execute(ActionMapping
> mapping,
> > > ActionForm form,HttpServletRequest request,
> > > HttpServletResponse response)
> > > throws Exception
> > > {
> > >
> > > //common code for all action classes
> > > CommonClass cc = new CommonClass();
> > > // just sample method
> > > cc.doValid();
> > > return performTask(mapping, form, request,
> > > response);
> > > }
> > > // this is the method which will be implemented
> by
> > > each overriding class and add the necessary
> logic
> > > protected abstract ActionForward
> > > performTask(ActionMapping mapping,
>
> > > ActionForm form,
> HttpServletRequest
> > > request,
> > > HttpServletResponse response)
> > > throws Exception;
> > >
> > > }
> > > I have a CommonClass for doing all the common
> > > function,
> > > How can i do it DispatchAction
> > > Ashish
> > >
> > > =====
> > > A$HI$H
> > >
> > >
> __________________________________________________
> > > Do you Yahoo!?
> > > Yahoo! Mail Plus - Powerful. Affordable. Sign up
> now.
> > > http://mailplus.yahoo.com
> > >
> > >
>
---------------------------------------------------------------------
> > > 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
>
=====
A$HI$H
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: Override DispatchAction but keep the existing funcationallity
Posted by Jerome Jacobsen <je...@gentootech.com>.
Correction. Your MyDispatchAction would not be abstract.
> -----Original Message-----
> From: Jerome Jacobsen [mailto:jerome.jacobsen@gentootech.com]
> Sent: Monday, February 03, 2003 11:29 AM
> To: Struts Users Mailing List
> Subject: RE: Override DispatchAction but keep the existing
> funcationallity
>
>
> Your CommonCode solution is the way I went (I called mine
> BaseActionHelper).
>
> Your subclass of DispatchAction would look something like this below.
>
> public abstract class MyDispatchAction extends DispatchAction
> {
> public ActionForward execute(ActionMapping mapping,
> ActionForm form,HttpServletRequest request,
> HttpServletResponse response)
> throws Exception
> {
>
> //common code for all action classes
> CommonClass cc = new CommonClass();
> // just sample method
> cc.doValid();
> return super.execute(mapping, form, request,
> response);
> }
> }
>
> > -----Original Message-----
> > From: Ashish Kulkarni [mailto:kulkarni_ash1312@yahoo.com]
> > Sent: Monday, February 03, 2003 11:17 AM
> > To: struts-user@jakarta.apache.org
> > Subject: Override DispatchAction but keep the existing funcationallity
> >
> >
> > Hi,
> > I want to extend functions of dispatchAction class,
> > like i want a class which extends DispatchAction and
> > overrides the execute method, But keep all the
> > existing functions,
> > But if i override the execute method, then i will have
> > to code the same function available in origianl
> > DispatchAction, and add my extra functions, ( like cut
> > and paste the code) but then if in future
> > DispatchAction is modified i will need to modify my
> > class.
> >
> > or have one class which will have all the functions of
> > DispatchAction , but also want to add more functions.
> >
> > What i have done in MyActionClass is
> > public abstract class MyAction extends Action
> > {
> > public ActionForward execute(ActionMapping mapping,
> > ActionForm form,HttpServletRequest request,
> > HttpServletResponse response)
> > throws Exception
> > {
> >
> > //common code for all action classes
> > CommonClass cc = new CommonClass();
> > // just sample method
> > cc.doValid();
> > return performTask(mapping, form, request,
> > response);
> > }
> > // this is the method which will be implemented by
> > each overriding class and add the necessary logic
> > protected abstract ActionForward
> > performTask(ActionMapping mapping,
> > ActionForm form, HttpServletRequest
> > request,
> > HttpServletResponse response)
> > throws Exception;
> >
> > }
> > I have a CommonClass for doing all the common
> > function,
> > How can i do it DispatchAction
> > Ashish
> >
> > =====
> > A$HI$H
> >
> > __________________________________________________
> > Do you Yahoo!?
> > Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> > http://mailplus.yahoo.com
> >
> > ---------------------------------------------------------------------
> > 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: Override DispatchAction but keep the existing funcationallity
Posted by Jerome Jacobsen <je...@gentootech.com>.
Your CommonCode solution is the way I went (I called mine BaseActionHelper).
Your subclass of DispatchAction would look something like this below.
public abstract class MyDispatchAction extends DispatchAction
{
public ActionForward execute(ActionMapping mapping,
ActionForm form,HttpServletRequest request,
HttpServletResponse response)
throws Exception
{
//common code for all action classes
CommonClass cc = new CommonClass();
// just sample method
cc.doValid();
return super.execute(mapping, form, request,
response);
}
}
> -----Original Message-----
> From: Ashish Kulkarni [mailto:kulkarni_ash1312@yahoo.com]
> Sent: Monday, February 03, 2003 11:17 AM
> To: struts-user@jakarta.apache.org
> Subject: Override DispatchAction but keep the existing funcationallity
>
>
> Hi,
> I want to extend functions of dispatchAction class,
> like i want a class which extends DispatchAction and
> overrides the execute method, But keep all the
> existing functions,
> But if i override the execute method, then i will have
> to code the same function available in origianl
> DispatchAction, and add my extra functions, ( like cut
> and paste the code) but then if in future
> DispatchAction is modified i will need to modify my
> class.
>
> or have one class which will have all the functions of
> DispatchAction , but also want to add more functions.
>
> What i have done in MyActionClass is
> public abstract class MyAction extends Action
> {
> public ActionForward execute(ActionMapping mapping,
> ActionForm form,HttpServletRequest request,
> HttpServletResponse response)
> throws Exception
> {
>
> //common code for all action classes
> CommonClass cc = new CommonClass();
> // just sample method
> cc.doValid();
> return performTask(mapping, form, request,
> response);
> }
> // this is the method which will be implemented by
> each overriding class and add the necessary logic
> protected abstract ActionForward
> performTask(ActionMapping mapping,
> ActionForm form, HttpServletRequest
> request,
> HttpServletResponse response)
> throws Exception;
>
> }
> I have a CommonClass for doing all the common
> function,
> How can i do it DispatchAction
> Ashish
>
> =====
> A$HI$H
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
>
> ---------------------------------------------------------------------
> 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