James,

What I normally do is create a "package" and set the defaults that I
want stuff to use (interceptors / interceptor stack / etc.). Then, I
just tell the convention plugin to use the package I configured....

The list of properties that the plugin uses is here -
http://struts.apache.org/2.x/docs/convention-plugin.html#ConventionPlugin-Configurationreference

I think the setting is -

struts.convention.default.parent.package        

-Wes

On Wed, May 12, 2010 at 9:39 AM, James Cook <james.c...@wecomm.com> wrote:
> That would be my favoured route.
>
> Wes, side question. Using the convention plugin can you modify the stack
> in the xml file so you don't have to annotate the action itself? Or do
> you still have to add the annotation with the interceptor put in?
>
> James
>
> -----Original Message-----
> From: Wes Wannemacher [mailto:w...@wantii.com]
> Sent: 12 May 2010 14:33
> To: Struts Users Mailing List
> Subject: Re: Some Spring/Struts questions
>
> I've seen a few responses, but I think the best way would be to write
> an interceptor that places the bean into the session. Give it a known
> name in the session, then you can use OGNL to access it... Here is a
> quick example of the interceptor -
>
> public class CustomInterceptor extends AbstractInterceptor {
>
>    private SomeBeanGeneratingService someBeanGeneratingService;
>
>    public String intercept(ActionInvocation invocation) throws
> Exception {
>       invocation.getSession().put("knownBeanName",
> someBeanGeneratingService.getBean());
>       return invocation.invoke();
>    }
>
>    public void setSomeBeanGeneratingService(SomeBeanGeneratingService
> someBeanGeneratingService) {
>        this.someBeanGeneratingService = someBeanGeneratingService;
>    }
> }
>
> The benefit is using an interceptor is two-fold... One is that it's
> pretty easy to unit test (compared to a Servlet Filter). Two is that
> it can be spring-configured and spring-injected.
>
> With this interceptor putting the bean into the session, you can
> access the bean's values through OGNL. Here is an example s:property
> tag retrieving some property -
>
> <s:property value="%{#session.knownBeanName.someProperty}" />
>
> Then, configure the interceptor and dependencies and put this
> interceptor in your stack.
>
> -Wes
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>



-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to