struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mohan Radhakrishnan <>
Subject RE: subclassing action
Date Tue, 03 Dec 2002 04:24:17 GMT
     We are using a standard base action but in this case the logic to
decide which perform method to call is based on a check in one of the
action's perform method.

     1. Call Action1 - Show reports the normal way.
     2. If reports are to be scheduled , call Action 2. Action2 can be a
sub-class of Action1 ?
     3. Action2's perform method should be called. 

 Action1 and Action2 differ . So Action2 is a subclass of Action1.


-----Original Message-----
From: Craig R. McClanahan []
Sent: Monday, December 02, 2002 10:27 PM
To: Struts Users Mailing List
Subject: Re: subclassing action

On Mon, 2 Dec 2002, Mohan Radhakrishnan wrote:

> Date: Mon, 2 Dec 2002 11:51:27 +0530
> From: Mohan Radhakrishnan <>
> Reply-To: Struts Users Mailing List <>
> To:
> Subject: subclassing action
> Hi,
>       I am looking for information on subclassing actions. Is there a way
> transfer control to the subclass if a certain check in the super action is
> valid ?
> Is this how this is done ? In normal OO, it happens based on polymorphism.
> How is it done with struts ?

A common technique in Struts based apps is to have a common base Action
that embeds functionality common to a set of your application's
requirements, such as customized login checking.  The general pattern
would be to have the common base class implement the public execute()
method (in 1.0 it was perform()), and then dispatch to business logic in
some other (usually protected) methods defined by the base class.

You can also do things like dynamically choose which business logic method
to call, based on request parameters.  This use case is so common that
Struts provides a standard base class
(org.apache.struts.actions.DispatchAction) for you.

> Thanks,
> Mohan


To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message