开发者

Problem changing language application

开发者 https://www.devze.com 2023-01-24 21:57 出处:网络
as I asked time ago in this question, I solved my problem using this method: In 开发者_StackOverflowloging.xhtm, for instance:

as I asked time ago in this question, I solved my problem using this method:

  1. In 开发者_StackOverflowloging.xhtm, for instance:

    <f:view locale="#{languageDetails.locale}" >
    <head>
    .....
    <f:loadBundle basename="messages.Messages" var="msg1"/>
    .....
    

      </h:form>
    

    </body>
    </f:view>
    

2.In java source code I also made some changes:

public class LanguageDetails {

    private static String locale = Locale.getDefault().getDisplayLanguage();

      public void setLocale(String locale1) {
        this.locale = locale1;
      }

      public synchronized String getLocale() {
        return locale;
      }

      public synchronized String changeLanguage() {
        return "changed";
      }
}

But now I'm trying to have the same option, not just in Login page, but in other pages.

Adding the same code in other pages, doesn't work, because function setLocale is not called. Any help?

Thanks in advance


I realized, it's really important to put

<f:view locale="#{languageDetails.locale}" >
....
</f:view>

Or in every single file, or just in top file. Later, put <h:selectOneMenu> where necessary, but having always in mind that you can not have all <h:form> , <a4j:form>... etc. you want, it makes things more complicated. I put this form tags just on top files, and now everything is ok.
Hope this could help somebody.

0

精彩评论

暂无评论...
验证码 换一张
取 消