1 Reply Latest reply: Aug 30, 2013 1:07 AM by Frank Nimphius-Oracle RSS

    Render page as per User language after login

    Jai Om-Oracle

      Hello,


       

      I am using Jdev 11.1.1.6 with ADFBC and Faces.

      In our application, user can set default language. It is expected that after login, all contents should be displayed as per user language locale (assuming locale is supported and locale specific resource bundle exists).

      So there is SignInPage and HomePage. I need to access the DB (using methodAction binding for a AM method, that reads the user preference and returns the language) before forwarding to HomePage.

       

      Code to forward to HomePage is something like this:

      FacesContext ctx = FacesContext.getCurrentInstance();

      RequestDispatcher dispatcher =

      request.getRequestDispatcher(forwardUrl);

       

      dispatcher.forward(request, response);

      ctx.responseComplete();

       

      End User locale handling is done by defining ViewHandler class in faces-config file. Implementation is explained here

       

      Problems faced:

      1) I tried to execute the operation binding but got null pointer...in FacesCtrlActionBinding._execute(FacesCtrlActionBinding.java:252)

      2) I tried to redirect using external.encodeActionURL(actionURL) but got illegalStateException...Response is already committed

       

      It works fine if user after login either just press F5 to refresh the page OR reset the language again using the preference screen.

       

      How do I get it to work at login? Where can I tap-in the methodAction call between SignInPage and HomePage, so that HomePage is rendered according to language?

       


      Any help/pointer is highly appreciated.


       

      Thanks,

      Jai

        • 1. Re: Render page as per User language after login
          Frank Nimphius-Oracle

          Hi,

           

           

           

          1) I tried to execute the operation binding but got null pointer...in FacesCtrlActionBinding._execute(FacesCtrlActionBinding.java:252)

           

           

          If you mean ADF operation binding then this only is available if a request is routed through the binding filter. Note that the PageDef file for a page needs to be parsed before the content becomes available as an object at runtime.

           

           

           

          2) I tried to redirect using external.encodeActionURL(actionURL) but got illegalStateException...Response is already committed

           

           

          Why don't you use facesContext --> externalContext --> redirect(...) to perform the redirect, The dispatcher.forward() surely doesn't do this

           

          3) How do I get it to work at login? Where can I tap-in the methodAction call between SignInPage and HomePage, so that HomePage is rendered according to language?


          Programmatic authentication as explained in the Fusion Developer Guide (chapter 30 if I recall correctly) would give you a chance to set the language. However, the language is not set on the ViewObject but should be set on JSF by changing the default language, e.g.


          FacesContext.getCurrentInstance().getViewRoot().setLocale(Locale.ENGLISH);


          Frank