You probably need to write a custom Interceptor. Struts 2 has a very nice 
feature called interceptors which is sort of like AOP which is great for 
cross-cutting problems e.g authentication. 

http://struts.apache.org/2.x/docs/interceptors.html
 
Cheers,

Drew Kutcharian
Venarc Inc.   www.venarc.com




----- Original Message ----
From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
To: user@struts.apache.org
Sent: Wednesday, April 18, 2007 12:10:44 AM
Subject: [s2]Would like each action to go throught my parent class


Hi all,

I would like to do as in Struts 1 with DispathAction : create a parent 
Action, which each other action extends, and each request/action passes by 
this parent action, and I could so add there the generic validations (user 
logged, etc...)

How could I do ?

I tried this :

My parent Action : 
public class CRMAction extends ActionSupport implements 
ServletRequestAware {
        private static final long serialVersionUID = 7543537304330132164L;
        private Logger log = Logger.getLogger(CRMAction.class);

        private HttpServletRequest request;

        @Override
        public String execute() throws Exception {
                //do all tests (user logged, ...)
                //...
                return super.execute();
        }
}

My others Actions :
public class LoginAction extends CRMAction {
        private static final long serialVersionUID = 
-5438115193615924021L;
        private Logger log = Logger.getLogger(LoginAction.class);

        public String myMethod () {
                //do something
                return "myForward";
        }
}

But I never go in CRMAction.execute()...

Thanks,

Regards,

Michaƫl

Reply via email to