Announcement Announcement Module
Collapse
No announcement yet.
Dynamic messages using attributeCSV Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dynamic messages using attributeCSV

    Helllo all

    I got an issue with dynmically get the messages based on the view's attributeCSV definitons, like teh country example.
    here are some of the related setups.

    view.properties
    [
    code]defaultParent.class=org.springframework.web.servle t.view.JstlView
    defaultParent.url=/jsp/common/MainTemplate.jsp
    defaultParent.requestContextAttribute=rc

    underconstruction.attributesCSV=htitle=[app.title],\
    content=[underconstruction.content][/code]
    part of the action-servlet.xml

    Code:
     <bean id="viewResolver"
        class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
        <property name="order"><value>0</value></property>
        <property name="basename">
            <value>view</value>
        </property>
        <property name="defaultParentView"><value>defaultParent</value></property>
      </bean>
    
      <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass"><value>org.springframework.web.servlet.view.JstlView</value></property>
        <property name="requestContextAttribute"><value>rc</value></property>
        <property name="redirectContextRelative"><value>true</value></property>
        <property name="cache"><value>true</value></property>
        <property name="prefix"><value>/jsp/</value></property>
        <property name="suffix"><value>.jsp</value></property>
      </bean>
    MainTemplate.jsp

    Code:
    !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@ include file="includes.jsp" %>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title><fmt:message key="htitle"/></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <c:if test="${not empty css}"><link rel="stylesheet" href="<c:url value="${css}"/>" type="text/css" /></c:if>
    </head>
    <body>
    <h1><fmt:message key="app.title"/></h1>
    <h1><fmt:message key="${htitle}"/></h1>
    </body>
    </html>
    the result I expected for the two message tags should be:
    Code:
    <h1>Spring Test</h1>
    <h1>Spring Test</h1>
    since app.title is defined as this in the message file.
    but what I got are:

    Code:
    <h1>Spring Test</h1>
    <h1>???${htitle}???</h1>
    apparently they tried to use the whole "${htitle}" to get the message.

    I did not see any difference of this app and the country example except that the jsps in this app are not in the web-inf dir. I assume this should not make a big difference here.

    Thanks a lot for your help.

    jfd

  • #2
    try this:
    <fmt:message><c:out value="${htitle}"/></fmt:message>

    or

    <spring:message code="${htitle}"/>

    out of my head though, but I think those do work

    HTH

    Comment


    • #3
      Thanks a lot, rharing.

      <fmt:message><c:out value="${htitle}"/></fmt:message> is not working and still give me the same result.

      <spring:message code="${htitle}"/> works at the message level.

      but I tried both in the

      <c:import url="${htitle}"/>

      and this still not working.

      jfd.

      Comment

      Working...
      X