2 Replies Latest reply on Apr 26, 2011 7:20 AM by Mano Swerts

    a4j:loadBundle alternative

    Mano Swerts Newbie

      Hi all,

       

      I used to use the a4j:loadBundle tag to dynamically change the language of the application using an a:commandLink. This worked great in RichFaces 3.3.2 and lower with JSF 1.2.

       

      At the moment I am working on a new application using JSF 2.1 and RichFaces 4 Final. The problem is that there is no a4j:loadBundle tag anymore. When using the f:loadBundle tag, the i18n messages are not reloaded correctly. I tried to wrap the entire f:view into an outputPanel, but that doesn't work.

       

      Is there any alternative solution for this?

       

      Thanks in advance.

        • 1. a4j:loadBundle alternative
          Ilya Shaikovsky Master

          try changing language by action using navigation rule this usually helps view to get rebuilt.

          • 2. Re: a4j:loadBundle alternative
            Mano Swerts Newbie

            Hi Ilya,

             

            Yes I tried that by changing the return type for the setLanguage method on my commandLink to String. It returns null it needs to stay on the same page, but this does not solve the problem.

             

            At the moment I solved it by adding a beforePhase attribute to the f:view tag like this:

             

             

            {code}

            beforePhase="#{loginBean.updateViewRootLanguage}"

            {code}

             

             

            The function in the backing bean looks like this:

             

             

            {code:java}

            public void updateViewRootLanguage(PhaseEvent event) {

                if (event.getPhaseId() == PhaseId.RENDER_RESPONSE) {

                    FacesContext.getCurrentInstance().getViewRoot().setLocale(new Locale(getAuthenticatedUser().getLanguage()));

                }

            }

            {code}

             

             

            This works great, but I don't know if this is a correct way to solve the problem.