Results 1 to 4 of 4

Thread: How to get info from messages.properties

  1. #1

    Default How to get info from messages.properties

    I have stored a constant by name [B]maxNumber=50[/B} in my messages.properties file. I am able to access this value in my jsp as follows:
    Code:
     <fmt:message var="Number" key="maxNumber"/>
    How do I call maxNumber from my messages.properties in my controller. Please let me know!

  2. #2
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    Make your Controller implement MessageSourceAware and use the MessageSource to access the maxNumber message.

  3. #3

    Default

    Quote Originally Posted by Dave Syer View Post
    Make your Controller implement MessageSourceAware and use the MessageSource to access the maxNumber message.
    Thanks for your help. I did try as follows:
    Code:
    class Sample implements MessageSourceAware {
    
    import org.springframework.context.MessageSource;
    import org.springframework.context.MessageSourceAware;
    import org.springframework.context.MessageSourceResolvable;
    
     private MessageSource messageSource;
    
     public void setMessageSource(MessageSource messageSource) {
    
            messageSource = messageSource;
     }
    
    public void foo(){
          messageSource.getMessage(maxNumber,x,y);
    }
    }
    What are these X and Y

    I have also included bean part in my configuration file as follows.
    Code:
    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
            <property name="basename"><value>messages</value></property>
        </bean>
    Please clarify about X(object) and Y(locale). Thanks again.

  4. #4
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    It's pretty clear in the JavaDocs from what I can see http://static.springframework.org/sp...a.util.Locale)
    Last edited by Dave Syer; Sep 28th, 2007 at 05:11 AM. Reason: tidy link

Posting Permissions

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