This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I've recently started working with tiles, taking advantage of tiles-def.xml and getting rid of extraneous jsp pages. However, unlike jsp, I haven't seen, nor am I aware of, a method to extract messages from application.properties to be used within tiles-def.xml. For example, in a jsp page, one could use <bean:message key="some.resource.message"> ... is there something similar that I could utilize within tiles-def.xml because I'd prefer to keep all messages in the resource bundle. But then again, I might be missing the point of using tiles by keeping messages in application.properties. Let me express my gratitude in advance to any and all that shed light on this matter. Thanks.
Joined: Dec 12, 2002
OK, I figured out how to do this and it was much simpler than I thought: explained through example. In your resource bundle, define a key with it's message (nothing new about this): first.five.letters=abcde In the tiles-def.xml, just enter the resource bundle key for the value of the 'put': <put name="message" value="first.five.letters" /> Lastly, in the view/template jsp page use tiles:useAttribute in combination with bean:message as follows: <tiles:useAttribute name="message"/> <bean:message key="<%=(String) message%>" /> Voila ... Why did I want to do this, you might be wondering ... I realize that tiles supports internationalization, but I wanted to avoid creating additional tiles xml files for each locale and keep a centralized approach to maintaining message resources