struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lukasz Lenart <>
Subject Re: implementaiton advise on custom TextProvider
Date Wed, 17 Oct 2012 05:56:11 GMT
2012/10/15 Davis, Chad <>:
> I'm not sure I follow you.  Just for clarity, let me restate my problem.  I have written
a custom extension of TextProviderSupport.  I want to have it
> injected as the framework's default TextProvider.  I have achieved this by configuring
it in struts.xml, declaring my implementation with a <bean/> element and then setting
the constant struts.xworkTextProvider to point at my bean.
> This works, but my implementation needs to be properly injected.  Right now, it's being
created with the default no-arg constructor.  How can I best have my dependencies injected
when the framework creates this bean?  What are my options?
> I restate this because it seems that you are suggesting that I override the ActionSupport
base class inorder to achieve this.  This seems to me to be skipping the framework and simply
creating and injecting my textprovider myself.  Perhaps I misunderstand.

You can use framework's internal DI mechanism, just define constants
and beans and use @Inject. Overriding or redefining base ActionSupport
class is the best approach for each application. ActionSupport can
support simple and common cases.

Maybe in other way. ValueStack (the root of all expression evaluation)
search values from top, thus means if an action is on top (and in many
cases it is) it will be taken first for evaluation. The same works for
TextProvider - take a look on ActionSupport, it implements
TextProvider interface as well. So if you don't care about supporting
framework internal messages, you can implement your own base action
class which will implement TextProvider interface and it can be
created by Spring, Guice and you can inject whatever you need ;-)


+ 48 606 323 122

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message