PDA

View Full Version : tiles q.



alex_b
Jan 22nd, 2005, 10:18 PM
Hi All,


How can I get searh.title from messages.properties in definitions.xml ?

this is a piece of definitions.xml which doesnt work
<definition name="template" page="/WEB-INF/jsp/layout.jsp">
<put name="title" value="searh.title" />
</definition>


thanks

alex_b
Jan 23rd, 2005, 10:13 AM
how can I pass a value from properties file using Tiles?


messages.properties
==============
searh.page.title = Search Page
searh.page.title =main page

layout.jsp
=========
<tiles:insert name="title"/>

definitions.xml
========
<definition name="template" page="/WEB-INF/jsp/layout.jsp">
<put name="title" value="searh.page.title" />
</definition>



thanks.

dhainlin
Jan 23rd, 2005, 08:36 PM
If I understand your question, you simply set the attrribute as you are doing in your definition. Your jsp would render it using something like

<fmt&#58;message key="$&#123;title&#125;"/>
(if using jstl)

this causes the tile attribute "title" to be resolved to "searh.page.title" which is
used by fmt to (or the spring version if desired) lookup the value from the appropriate bundle.

Hope that helps.

alex_b
Jan 24th, 2005, 09:11 AM
If I understand your question, you simply set the attrribute as you are doing in your definition. Your jsp would render it using something like

<fmt&#58;message key="$&#123;title&#125;"/>
(if using jstl)

this causes the tile attribute "title" to be resolved to "searh.page.title" which is
used by fmt to (or the spring version if desired) lookup the value from the appropriate bundle.

Hope that helps.

there 2 pages. I need to get different titles for each of them from properties file.
in each page I have:
<tiles:insert name="title"/>

messages.properties
==============
searh.page.title = Search Page
main.page.title =main page

in definitions file I'm trying to use
<definition name="main" extends="template">
<put name="title" value="main.page.title" />
<put name="body" value="/WEB-INF/jsp/main.jsp" type="page"/>
</definition>

<definition name="search" extends="template">
<put name="title" value="search.page.title" />
<put name="body" value="/WEB-INF/jsp/include/search.jsp" type="page"/>
</definition>

I tried to use <fmt:message key="${title}"/>, but it didnt work.
am I missing something?

thanks.

stueccles
Jan 24th, 2005, 10:11 AM
try
<tiles:importAttribute name="title"/>
<fmt:message key="${title}"/>

alex_b
Jan 24th, 2005, 12:29 PM
try
<tiles:importAttribute name="title"/>
<fmt:message key="${title}"/>

thanks a lot. now it works.