Results 1 to 4 of 4

Thread: Get localized messages in JSP and default locale

  1. #1
    Join Date
    Aug 2004
    Location
    Southern Germany
    Posts
    30

    Default 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.
    Regards,
    Lars Fischer
    http://j2ux.blogspot.com

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

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

  3. #3
    Join Date
    Aug 2004
    Location
    Southern Germany
    Posts
    30

    Default

    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.
    Regards,
    Lars Fischer
    http://j2ux.blogspot.com

  4. #4
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

Posting Permissions

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