Greetings,
I?m trying to change the locale of only 1 page in my web app.  The system 
as a whole allows for a variety of locales, but 1 page in particular is 
displayed in a data specified locale.  I?ve tried 
myPage.setLocale(Locale.GERMAN), before activating the page, but that just 
seems to result in a ApplicationRuntimeException.  So I created a work 
around, in the specially localized page I did:

    public void pageBeginRender(PageEvent event)   {
        super.pageBeginRender(event);
        if (!event.getRequestCycle().isRewinding())   {
            Locale dataLocale = new Locale(getData().getLanguage());
            if (getEngine().getLocale().equals(dataLocale) == false)
            {
                getEngine().setLocale(dataLocale);
                event.getRequestCycle().cleanup();
                throw new PageRedirectException(this);
            }

            AppVisit visit = (AppVisit) getVisit();
            App app  = visit.getSession();

            getEngine().setLocale(app.getDefaultLocale());
        }
}


Which should check to see if the current locale is different than the data 
locale, change the engine locale to the data locale, refresh the page.  If 
the two locales are the same, then reset the locale to the default locale. 
 

This seems to work fairly well, except when the user logs out.  When the 
user logs out we do ((IEngineServiceView) 
cycle.getEngine()).restart(cycle), and redirect to the login page.  When 
that redirection happens, the user?s locale seems to be whatever the data 
locale was. 

So as an example, the user logs in in English, browses to the data sees it 
in German, then browses other pages (back in English).  When the user logs 
out, for some reason they get presented with a German login screen.  Their 
browser is set to English, the session default is English, only that data 
page is in German.

Mostly I dislike messing with the engine locale, I?d like to just set it 
for the specific page, but I haven?t figured out how. 

Ideas for what I?m doing wrong, or possible alternatives?

Thanks!

Chris

Reply via email to