you can do the same thing passing the strings keys in the tiles, then play with the jsp pages using JSTL <fmt tag..>

<tiles:importAttribute name="titleKeyParameter1" />

<fmt:message var="parameter1Value" value="${titleKeyParameter1}"/>

<fmt:message key="foo">
  <fmt:param><c:out value="${parameter1Value}"/></fmt:param>
  ... //repeat process....
</fmt:message>

I'm pretty sure you should be able to also put <fmt> tags within <fmt> tags (nested), but I've never tried it.



Peter Rumstle wrote:
Thats an excellent solution for the i18n part. I will change my code to use this method.
I still don't know what the best way to add variables to the title tho.  I know 
i can have variable placeholders in my resource file ex.

resource_en.properties
record.detail.title=Record Detail:{0}
user.detail.title=User Detail:{0}
application.title=Hello World Application

tiles.xml
<definition name="foo" extends=".template">    <put name="titleKey" value="record.detail.title" 
type="string"/></definition>

jsp template page
// Somehow i need to pass in optional variables that are provided by my 
controller to the title
<fmt:message key="${titleNameKey}"/>


Is this possible with tiles?

btw, sorry for posting to two mailing lists about this if thats bad form.




Date: Thu, 20 Dec 2007 13:29:32 -0500
From: [EMAIL PROTECTED]
To: user@struts.apache.org
Subject: Re: i18n and variable tiles definitions

May I suggest to instead of using the "title" value in the tiles, use the keys (e.g. "titleKey"), then fetched it using whatever approach you want to:

Example:

resource_en.properties

application.title=Hello World Application


tiles.xml

<definition name="foo" extends=".template">
   <put name="titleKey" value="application.title" type="string"/>
</definition>

jsp page

<c:set var="titleNameKey"><tiles:getAsString name="titleKey"/></c:set>

<fmt:message key="${titleNameKey}"/>

(of course this uses unnecessary code, but the above will work for sure)

Hope this helps!


Peter Rumstle wrote:
Hi everyone, I am running into what appears to be a limitation in tiles. I hope someone has encountered this problem before and knows of a workaround.
I have a tiles based layout that accepts a "title" in the tiles definition.

    <definition name="recordDetail" extends=".template">
        <put name="title" value="Record Detail"/>
        <put name="body" value="/WEB-INF/jsp/tiles/recordDetail.jsp"/>
    </definition>

My problem is that I need the title to be more dynamic.  It needs to do two 
things:

1. Support different titles depending on the locale.
2. Accept a dynamic field identifying the record number that the page is 
showing.

For example, rather than say "Record Detail" like in my example it should say "Record Detail: 
38847829" and in other languages it should be translated using an existing ResourceBundle (ex. 
"Detalle De registro: 38847829").

My problem lies in the fact that my .template tile includes the <title> tag, but does not 
know which page it is rendering.  Only the "body" tile and the actual tiles 
definition knows which page it is rendering for.  Other pages use the same .template tile but 
require different dynamic fields in their title.

Has anyone got something like this working before?

Thanks!

_________________________________________________________________
Introducing the City @ Live! Take a tour!
http://getyourliveid.ca/?icid=LIVEIDENCA006
--

Alberto A. Flores
http://www.linkedin.com/in/aflores



_________________________________________________________________
Discover new ways to stay in touch with Windows Live! Visit the City @ Live 
today!
http://getyourliveid.ca/?icid=LIVEIDENCA006

--

Alberto A. Flores
http://www.linkedin.com/in/aflores


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

Reply via email to