aspose file tools*
The moose likes Struts and the fly likes Using messages in resource bundle in tiles-def.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Using messages in resource bundle in tiles-def.xml" Watch "Using messages in resource bundle in tiles-def.xml" New topic
Author

Using messages in resource bundle in tiles-def.xml

Tom Kata
Greenhorn

Joined: Dec 12, 2002
Posts: 7
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.
Tom Kata
Greenhorn

Joined: Dec 12, 2002
Posts: 7
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
Jochen Maes
Greenhorn

Joined: Dec 03, 2002
Posts: 20
nice workaround, hmm might come in handy, thanks for sharing
 
jQuery in Action, 2nd edition
 
subject: Using messages in resource bundle in tiles-def.xml