Announcement Announcement Module
Collapse
No announcement yet.
programatically looking up a i18n value from messageSource Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • programatically looking up a i18n value from messageSource

    Is there a way to programatically lookup an i18n key from a configured messageSource? I'm working with some tags that are not EL aware and I need to pass in a label value after doing to i18n lookup.

    Thanks,
    Sanjiv

  • #2
    I figured out how to do this. Incase anyone else is interested, here's how I did it.

    Basically add the bean property 'requestContextAttribute' on the InternalResourceViewResolver as below. 'requestContextAttribute' is of type org.springframework.web.servlet.support.RequestCon text and is made available as a request attribute ("rc", in this case) to the view and has convenience methods to look up messages from the configured messageSource.

    <bean id="viewResolver" class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
    <property name="viewClass"> <value>org.springframework.web.servlet.view.JstlVi ew</value>
    </property>
    <property name="requestContextAttribute"><value>rc</value></property>
    <property name="prefix">
    <value>/jsp/</value>
    </property>
    <property name="suffix">
    <value>.jsp</value>
    </property>
    </bean>

    Comment

    Working...
    X