You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John Yu <jo...@scioworks.com> on 2002/08/27 06:00:45 UTC
Re: What if you need all your dispatchAction methods to call a
common method?
Does overriding the execute()/perform() method in the DispatchAction do the
work?
public class YourDispatchAction extends DispatchAction {
public Forward execute(...) throws Exception {
preExecute(...);
return super.execute(...);
}
abstract public void preExecute();
}
At 05:15 am 27-08-2002, you wrote:
>Before I get yelled at for handling if a user logged in by the
>application and not by the container, let me first explain it's not my
>first choice to do it this way... it's a long story but just wanted to
>set that out before I get e-mails about not having the struts
>application deal with a user being logged in.
>
>All my actions funnel through one DispatchAction class. The question I
>have is "Is there a way to have all of the methods in this action call
>some other common method before they perform their own action related
>stuff?" To be specific in this case, I need to make sure a bean stored
>in their session hasn't become null if their session has expired
>before continuing on with the action method. If the session bean is
>null I want to redirect them back to the login page with the message
>"Session has timed out."
>
>Is there a way that a DispatchAction will always call some other
>method first where I can place some generic code that all the
>dispatchAction methods will thus execute? Otherwise I guess I have to
>check for the state of the bean in the session in every single
>dispatchAction method.
>
>Thanks for any ideas.
>--
>Rick
--
John Yu Scioworks Technologies
e: john@scioworks.com w: +(65) 873 5989
w: http://www.scioworks.com m: +(65) 9782 9610
Scioworks Camino - "Don't develop Struts Apps without it!"
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>