Hi! My application stores localized messages in the database. It's a big application, and each customer wants a lot of customization. So for every framework we use, we need to plug into the message system to get what we want. Every call to messages.get('validation-error-required') needs a parameter for languageId/locale and customerId. And it must be retrieved from the database, not from a resources file.
For Struts, I replaced the entire Struts message system with my own custom tag. For T4, I contributed my own service in hivemodule.xml. The entire implementation is listed below if someone should find this interesting/useful. I injected the servlet request, where user/customer info is stored in the session, into my service, and did the DB-calls from there. In T5, I'm looking for a similar solution. So far I have found the following interesting places in TapestryModule, does anyone feel like pointing me in the right direction? public ComponentMessagesSource buildComponentMessagesSource public void contributeValidationMessagesSource(Configuration<String> configuration) public ValidationMessagesSource buildValidationMessagesSource T4 custom messages implemtation: <service-point id="ComponentMessagesSource" interface="org.apache.tapestry.services.ComponentMessagesSource"> Used to provide components (including pages) with access to their own localized messages. <invoke-factory> <construct class="common.tapestry.ComponentMessagesSourceImpl"> <set-object property="request" value="service:tapestry.globals.HttpServletRequest" /> </construct> </invoke-factory> </service-point> public class ComponentMessagesSourceImpl implements ComponentMessagesSource { static Log log = LogFactory.getLog(ComponentMessagesSourceImpl.class); private HttpServletRequest request; public void setRequest(HttpServletRequest request) { this.request = request; } public Messages getMessages(IComponent component) { return new MessagesTapestryWrapper(request); } } public class MessagesTapestryWrapper implements org.apache.hivemind.Messages { static Log log = LogFactory.getLog(MessagesTapestryWrapper.class); private HttpServletRequest request; public MessagesTapestryWrapper(HttpServletRequest request) { this.request = request; } public String format(String key, Object arg0) { Object[] args = { arg0 }; return format(key, args); } public String format(String key, Object arg0, Object arg1) { Object[] args = { arg0, arg1 }; return format(key, args); } public String format(String key, Object[] args) { return Lang.get(request, key, args); } public String format(String key, Object arg0, Object arg1, Object arg2) { Object[] args = { arg0, arg1, arg2 }; return format(key, args); } public String getMessage(String key) { String message = Lang.get(request, key); return message; } }