personally I do overwrite execute in my baseaction and define an
abstract doExecute which all extending classes has to implement and
which is called by the execute method of the BaseAction after all
checks are done.

My BaseAction usually also define methods which can be overridden by
the extending actions to tell the BaseAction how to behave, for
example:
boolean loginRequired() -> if true check if the user is logged in
before calling doExecute
int permissionsRequired()
boolean sessionRequired()
and so on.

What BaseActions also can do is to instantiate and manage resources
(yes servlet content listener can do this too, but i like to have it
in one place), services and so on. They also provide methods to handle
request parameters typed (getStringParameter, getIntParameter) for
pages which don't use forms.

To put it simple
If you have to do something similar in two actions, put it into helper
class. If it's more than two, put it in the baseaction (or the call to
the helper in the base action). It is also good to have an application
wide base action, and a base action hierarchy for modules (if you have
more than one). BaseAction -> BaseMessagingAction ->
SendMessageAction.

Btw, I think it's a serious design flaw in struts the Action class is
not abstract.

regards
Leon


On 10/6/05, Koen Jans <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am trying to use a BaseAction class for my action, and i have been
> wondering what to put in there;
>
> As for now, i have put the basic stuff there like finding a forward for
> a database faillure and so on..
> (like in the mailreader example by the way). Also, i have put a method
> that retrieves a handler from
> the servlet context that all actions need. Is this a good idea?
>
> I wonder whether it's a good idea to do authorization in the base class
> by implementing an abstract
> execute method that will check whether a user is logged in.. All action
> classes then will first call
> this abstract execute method.
>
> What do you put in base classes?
> Thanks
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to