PDA

View Full Version : I18N on some values from tiles definition



pankajvermani
Aug 10th, 2005, 11:56 AM
I have a web application using spring MVC. My tiles definition look like this:


<definition name="template" page="/tiles/mainTemplate.jsp" controllerClass="com.tf.app.geoapp.ui.controllers.util.MainTemplate Controller" >
<put name="title" value="Application"/>
<put name="content" value="/error.jsp"/>
</definition>

<definition name="login" extends="template">
<put name="title" value="Login Screen"/>
<put name="content" value="/login.jsp" type="page"/>
</definition>


The template jsp looks like:

<head>
<title>
<fmt&#58;message key="site.name"/>&#58; <tiles&#58;getAsString name="title" />
</title>
</head>
<body>
<tiles&#58;insert name="content" />
</body>


As visible by the fmt tag in jsp, I am using I18N, in the application. Now i wish to access "title" values coming from the tiles definition (i.e. "Login Screen" ) to be actually a key (say "login.title") which gets mapped to the messages.properties, and finally that property value gets rendered on the screen. Any ideas on how to do that?

Can anyone help me at that?

Thanks

gomtuohe904
Nov 6th, 2006, 04:56 AM
Hi,

I'm not using "<fmt:message" to I18N my webapp. But this could be a solution for your problem:

<head>
<tiles:useAttribute id="key" name="title"/>
<title><spring:message code="${key}"/></title>
</head>

As long as "fmt" supports EL (it should, but not sure), just replace "<spring:message" with "<fmt:message".