yes

Peter Rumstle wrote:
So I've found a method that works.  Perhaps it s what you were trying to 
explain in the first place.

Rather than use an EL expression in the tiles definition to say which object should be used in the page title key parameter, I just define a parameter called titleKeyParam1 that the controller will optionally set directly. There is nothing about the parameters in the tiles definition file, only the titleKey.
ie.
tiles-layout.xml
    <definition name="recordDetail" extends=".template">        <put name="titleKey" 
value="record.detail.title"/>        <put name="body" value="/WEB-INF/jsp/tiles/recordDetail.jsp"/>    </definition>


jsp file        <fmt:message key="${titleNameKey}">            <fmt:param><c:out 
value="${titleKeyParam1}"/></fmt:param>        </fmt:message>


- Then the controller optionally sets the titleKeyParam1 as an object in the 
model.




From: [EMAIL PROTECTED]
To: user@struts.apache.org
Subject: RE: i18n and variable tiles definitions
Date: Thu, 20 Dec 2007 13:47:33 -0800


btw, I've also tried this slight variation:

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

Which gives me the page title:  "Record Detail: ${recordId}".  Also giving me 
the problem that it is not evaluating the expression.



From: [EMAIL PROTECTED]
To: user@struts.apache.org
Subject: RE: i18n and variable tiles definitions
Date: Thu, 20 Dec 2007 13:41:13 -0800


This idea seems really promising, but I have been unable to implement it.  Here 
is what I have tried:


resource_en.properties
record.detail.title=Record Detail:{0}
tiles.xml
<definition name="foo" extends=".template">     <put
name="titleKey" value="record.detail.title"
type="string"/>    <put
name="titleKeyParam1" value="recordId"
type="string"/></definition>

jsp template page
<c:set var="titleNameKey"><tiles:getAsString name="titleKey"/></c:set><c:set var="titleNameKeyParam1"><tiles:getAsString 
name="titleKeyParameter1"/></c:set><fmt:message key="${titleNameKey}">    <fmt:param><c:out 
value="${titleNameKeyParam1}"/></fmt:param></fmt:message>


My controller passes to the jsp view a parameter called "recordId".  I know 
that is working because I can use the value elsewhere.

The problem is that my title displays as: "Record Detail: recordId" instead of 
showing me the value of ${recordId}
(I expected something like "Record Detail: 12345")

I've tried a few variations on this without success :-(   How can I get the 
title to show the value of the expression i set in my tiles definition?




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

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


_________________________________________________________________
Introducing the City @ Live! Take a tour!
http://getyourliveid.ca/?icid=LIVEIDENCA006
_________________________________________________________________
Use fowl language with Chicktionary. Click here to start playing!
http://puzzles.sympatico.msn.ca/chicktionary/index.html?icid=htmlsig

_________________________________________________________________
Exercise your brain! Try Flexicon!
http://puzzles.sympatico.msn.ca/chicktionary/index.html?icid=htmlsig

--

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