You can do something like this :
In your tiled definition : 

--snip--
        <put name="messageText" value="message.text"/>
--snip--

In your jsp:

Do something like

<tiles:getAsString name="messageText"/>

<title><bean:message name="messageText"/></title>

So in the <title>... a value corresponding to the value of messageText which
is message.text will be fetched in the resources and will be replaced.

So in short in the tiles definition instead of the value of the messageText
("Hello") put a key ("message.text") of the resources for that particular
message and later get it in the usual way as shown.

HTH
Avinash





-----Original Message-----
From: Václavík Radek [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 09, 2004 8:35 AM
To: '[EMAIL PROTECTED]'
Subject: Localization within Tiles

Hi all,

(sorry for a bit longer message)

I have encountered an interesting problem. In my struts application I am
using tiles and localization through ApplicationResources.properties files.

In my jsp page I have messages written as:
<bean:message key="label.messageText"/>

however, sometimes I would like to refer to a value defined in tiles. Such
as:
<tiles:getAsString name="messageText"/>

In the tilesDefinition.xml file I have e.g.:
--snip--
        <put name="messageText" value="Hello"/>
--snip--

What I would like to do is to combine these 2 approaches and have localized
messageText without needing to rewrite it in tiles def. file. Because this
is the case in the "tiles-documentation" example supplied with tiles:
<definition.....>
        <put name="messageText" value="Bye"/>
</definition>
and in another language in tiles def. _de:
<definition.....>
        <put name="messageText" value="Tshus"/>
</definition>

But this implies a lot of (imho) unnecessary typing.


The solution I've had in mind would go something like this:
<definition ....>
        <put name="messageText" value="label.messageText"/>
</definition>

and in the jsp there would be:
<bean:message key="<tiles:getAsString name="messageText""/>

That way I would have all the localized strings in .properties files only.
But unfortunately such nesting is not possible. I have tried using scripting
variables (as I have been facing this kind of nesting problems more often)
but did not succeed.

I would appreciate any comments how to solve this issue. Thanks.

Regards,

Radek

_____________________________

Ing. Radek Václavík
ICS Department - webmaster

ZeNTIVA a.s.
U Kabelovny 130, 102 37 Praha 10
Czech Republic
tel. +420 267 243 296
_____________________________


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to