SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JSF - change language problem

    Hi,

    I'm learning jsf and i have a problem with a recent test. How can i change the language of my pages and keep it to the next pages ?
    To summarize i want that one user can change a page to another language and keep this setting for all the time he stay connected.

    I can do it for one page but if i go to the next one i return to the default language

    For the moment i have this :
    Code:
    in jsp page :
    <h:commandLink action="#{languageSwitcher.switchOnEn}" immediate="true">
      <h:graphicImage value="img/en.jpg" width="30px" height="20px" style="border:0px"/>
    </h:commandLink>
    ...
    
    in class LanguageSwitcher :
    public String switchOnEn() {
      FacesContext context = FacesContext.getCurrentInstance();
      context.getViewRoot().setLocale(Locale.ENGLISH);
      return null;
    }
    ...
    
    in config.xml:
    <managed-bean>
      <managed-bean-name>languageSwitcher</managed-bean-name>
      <managed-bean-class>test.LanguageSwitcher</managed-bean-class>
      <managed-bean-scope>session</managed-bean-scope>(request?)
    </managed-bean>
    Any ideas ?

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I discover that the problem is on the "viewRoot" level which is attach to the page.
    is an other way to set the locale ?

  3. #3
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by perezoso
    I discover that the problem is on the "viewRoot" level which is attach to the page.
    is an other way to set the locale ?

    Hello perezoso!

    have you got a solution to that problem?
    i have the same problem.

    thank you,

    grue


Bookmarks

Posting Permissions

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