GF wrote:
Hi everyone.
I have many packages that extends extends="tiles-default".
I would like to add an interceptor to all of them.
Now I'm doing this:
<package name="myPackage" extends="tiles-default" namespace="/myspace">
<interceptors>
<interceptor name="myInter" class="myInterceptor" />
<interceptor-stack name="myStack">
<interceptor-ref name="myInter" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="myStack"/>
.......
</package>
But I should do this to Every one.. and it is not nice..
Can you suggest me a quicker (and more elegant) way?
Sure: define the stack once, then reference it from each of your packages:
<package name="default" extends="tiles-default" abstract="true">
<interceptors>
<interceptor name="myInter" class="myInterceptor" />
<interceptor-stack name="myStack">
<interceptor-ref name="myInter" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="myStack"/>
</package>
<package name="myPackage" extends="default" namespace="/myspace">
...actions...
</package>
See the Interceptors guide [1], especially the Stacking Interceptors
section and the first item in the FAQs [2] at the end.
L.
[1] http://struts.apache.org/2.0.11/docs/interceptors.html
[2]
http://struts.apache.org/2.0.11/docs/how-do-we-configure-an-interceptor-to-be-used-with-every-action.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]