On 31.07.2014, Thiago H de Paula Figueiredo wrote:

>> I am wondering if it possible to extend the list with my own resource.
> Yep! Do what Tapestry itself does: contribute ObjectProvider instances to  
> the MasterObjectProvider service. For example, injection of symbol values  
> using @Symbol is implemented by SymbolObjectProvider.

I had a look at the implementation of TapestryModule and had the feeling
that the MasterObjectProvider only covers global objects without a
reference to the calling component. Did I miss something?

>> What I have in mind is a custom messages resource which is aware of the  
>> current component/page and also has access to the current locale as well  
>> as another injected service. I want to use it to extend the solution  
>> mentioned in my earlier thread "Product-line specific component  
>> messages".
> Wasn't the solution we built enough? Why?

The solution you provided is elegant and works perfectly well on
messages specified in the TML. However, it does not affect any messages
evaluated using an injected messages object, like when performing
Messages.format(String, Object...) in a component.

What we did now is introducing a new axis (the product line) for the
component resource locator as explained in [0]. A custom
PageRenderRequestFilter parses the activation context and sets the
current product line. The modified resource locator then adds the
modified property-files to the list of parsed resources. This way we can
add a new product-line easily just by adding files like
"Component-productlinename(_locale).properties" which only override
specific keys. The advantages are:

- No more setting the product line in onActivate
- Same keys in all property-files
- Same message prefix as before, existing code does not have to be
  changed
- Works for both TML expressions and injected messages
- Product lines may be added by adding a JAR file to the classpath

We are currently preparing an example application based on the Maven
archetype. I can post the link once it is available, if you are interested.

Again, thank you very much for your continued support on this mailing
list, it is greatly appreciated!

Regards
 Stephan

[0] http://blog.tapestry5.de/index.php/2011/06/24/template-skinning/

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to