struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Cook" <James.C...@wecomm.com>
Subject RE: Some Spring/Struts questions
Date Wed, 12 May 2010 14:03:15 GMT
Ah, awesome. Thank you for clearing that one up and your package is defined in the struts.xml
in the root of the source?

-----Original Message-----
From: Wes Wannemacher [mailto:wesw@wantii.com] 
Sent: 12 May 2010 14:51
To: Struts Users Mailing List
Subject: Re: Some Spring/Struts questions

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.Cook@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:wesw@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-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@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-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


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


Mime
View raw message