Results 1 to 6 of 6

Thread: tiles q.

  1. #1
    Join Date
    Jan 2005
    Posts
    7

    Default tiles q.

    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

  2. #2
    Join Date
    Jan 2005
    Posts
    7

    Default Re: tiles q.

    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.

  3. #3
    Join Date
    Nov 2004
    Location
    Dallas, TX (USA)
    Posts
    58

    Default

    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
    Code:
    <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.
    Sleep is for the weak

  4. #4
    Join Date
    Jan 2005
    Posts
    7

    Default

    Quote Originally Posted by dhainlin
    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
    Code:
    <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.

  5. #5
    Join Date
    Oct 2004
    Location
    London, UK
    Posts
    71

    Default

    try
    <tiles:importAttribute name="title"/>
    <fmt:message key="${title}"/>
    Stuart Eccles
    Technical Consultant

  6. #6
    Join Date
    Jan 2005
    Posts
    7

    Default

    Quote Originally Posted by stueccles
    try
    <tiles:importAttribute name="title"/>
    <fmt:message key="${title}"/>
    thanks a lot. now it works.

Similar Threads

  1. Replies: 2
    Last Post: Oct 24th, 2005, 07:52 AM
  2. Replies: 1
    Last Post: Oct 21st, 2005, 05:27 AM
  3. Tiles and Localisation
    By dan_pretty_boy in forum Web
    Replies: 2
    Last Post: Feb 24th, 2005, 03:06 AM
  4. Replies: 2
    Last Post: Feb 10th, 2005, 03:17 PM
  5. More Spring & Tiles examples/tutorials?
    By michael in forum Web
    Replies: 1
    Last Post: Dec 5th, 2004, 03:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •