Announcement Announcement Module
Collapse
No announcement yet.
Get localized messages in JSP and default locale Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Get localized messages in JSP and default locale

    1. How can I retrieve the following as text from a JSP (for use as a JavaScript parameter):
    Code:
    errors.rejectValue("person.name", "errors.required", new Object[]{"Name"}, "Value required.");
    There have been posts about the RequestContextAttribute but no concrete JSP example.

    2. How can I change a user's locale via program code in Spring ?

    In WebWork, you have to override a certain method to set the locale you want to use.

  • #2
    2. How can I change a user's locale via program code in Spring ?
    Look at Spring countries sample and Spring's LocaleChangeInterceptor.

    Comment


    • #3
      I still need an answer regarding question 1.

      I've defined this in my viewResolver:

      <property name="requestContextAttribute"><value>rc</value></property>

      and I can access the contextPath in my JSP like

      ${rc.contextPath}

      But all other properties of the RequestContext I've tried don't work. For example

      ${rc.message("frombundle")} or ${rc.getMessage("frombundle")}

      always throw a ServletException:

      "The function message must be used with a prefix when a default namespace is not specified"

      I still must be able to retrieve the error message like outlined above in my JSP. Otherwise I'm not able to use localized JavaScript errors.

      The JavaDocs are not very clear regarding this point. "rc.contextPath" does work but other methods do not.

      Comment


      • #4
        Would http://www.springframework.org/docs/...essageTag.html help?

        Comment

        Working...
        X