Leon Rosenberg wrote: >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.
thanks, this looks pretty good and helpfull. >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. I am not sure how you can manage a resource in the BaseAction, let's take for instance a Database or a Logger object. The users guide on the struts website states that we can only use local variables in an Action class to be thread safe in a multi-threaded environment. (http://struts.apache.org/userGuide/building_controller.html#action_design_guide) Of an action class, only one instance is created to service all requests; so is it safe to turn the above statement around and _do_ use an instance variable "Logger logger" and "Database database" in the Base Action class, of which in fact we want one and only one instance to be created? Or am i missing a point here? Thanks again >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] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]