Announcement Announcement Module
Collapse
No announcement yet.
tiles q. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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.

      Comment


      • #4
        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.

        Comment


        • #5
          try
          <tiles:importAttribute name="title"/>
          <fmt:message key="${title}"/>

          Comment


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

            Comment

            Working...
            X