Results 1 to 3 of 3

Thread: Dynamic messages using attributeCSV

  1. #1
    Join Date
    Nov 2004
    Posts
    20

    Default 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. #2
    Join Date
    Aug 2004
    Posts
    29

    Default

    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

  3. #3
    Join Date
    Nov 2004
    Posts
    20

    Default

    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.

Similar Threads

  1. Newbie: logging acegi messages
    By cwong in forum Security
    Replies: 2
    Last Post: Sep 28th, 2007, 05:47 PM
  2. Replies: 2
    Last Post: Jul 14th, 2007, 09:05 AM
  3. Replies: 4
    Last Post: May 12th, 2006, 02:50 AM
  4. getting messages from the message source
    By derrickhackman in forum Web
    Replies: 10
    Last Post: Sep 27th, 2005, 04:27 PM
  5. Replies: 7
    Last Post: Aug 1st, 2005, 01:38 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
  •