Dear Gunnar, did you by chance find a solution to this problem? I seem to have the same problem with a very similar implementation of the PPGK. As soon as I remove the PPGK the locale is switched correctly. If I leave it in, the locale is always en_US even if this is not in the SUPPORTED_LOCALES.
Cheers and thanks Daniel On 31.10.2009, at 09:30, Gunnar Eketrapp wrote: > And here is the relevant part from PPGK > > /** > * Check the rights of the user for the page requested > * > * @throws IOException > */ > public boolean checkAccess(String pageName, Request request, Response > response) throws IOException { > boolean canAccess = true; > > > /* Is the requested page private ? */ > Component page = componentSource.getPage(pageName); > ProtectedPage pp = > page.getClass().getAnnotation(ProtectedPage.class); > boolean protectedPage = pp != null; > > if (protectedPage) { > // logger.debug("checkAccess: " + pageName); > canAccess = false; > > // If User exists and he has the required role give him access > if (sessionStateManager.exists(User.class)) { > User user = sessionStateManager.get(User.class); > canAccess = user.isSuperAdmin() || user.hasRole(pp.role()); > if (!canAccess) > logger.debug("User " + user + " Role " + pp.role() + " > needed by page " + pageName); > } > } > > /* > * This page can't be requested by a non-authenticated user => we > redirect him to the LogIn page > */ > if (!canAccess) { > if (page != null) { > // Setup Login page to redirect to the secured page after > the login > Object obj = componentSource.getPage(Login.class); > ILogin login = (ILogin) obj; > login.setRedirectTo(page); > } > response.sendRedirect(request.getContextPath() + LOGIN_PAGE); > return true; // Make sure to leave the chain > } > > return false; > } > > > 2009/10/31 Gunnar Eketrapp <gunnar.eketr...@gmail.com> > >> Hi! >> >> This morning I made a test since I suspected that it was the introduction >> of the ProtectedPageGateKeeper that hade sideeffects on the locale handling. >> >> When I removed the PPGK everyhting worked as normal! >> >> So now I am investigating why the PPGK dispacther interferes with T5's >> locale handling. >> >> A clue anyone? >> >> >> /Gunnar >> >> 2009/10/30 Gunnar Eketrapp <gunnar.eketr...@gmail.com> >> >>> Hi ! >>> >>> Given these injections ... >>> >>> @Inject >>> private PersistentLocale persistentLocale; >>> >>> @Inject >>> private Locale currentLocale; >>> >>> ... what should be the value of currentLocale. I.e. after that the >>> persistent locale has been set, should curentLocale follow? >>> >>> I will conduct tests tomorrow with a minimal project but the locale >>> handling in my project is quite fucked up right now and it is driving me >>> crazy. >>> >>> I assume that it should just be to call persistentLocale.set() in an >>> action link method and after that things should work. But for me they are >>> not ... >>> >>> /Gunnar >>> >>> >>> >>> 2009/10/30 Gunnar Eketrapp <gunnar.eketr...@gmail.com> >>> >>>> Hi! >>>> >>>> The code below is not PROD ready yet. The first section is to setup input >>>> fields with label inside them. >>>> Something that our "designers" seems slick! >>>> >>>> The state locale is used it to remember the locale when called from a >>>> flash menu >>>> that "discarded" the persistent locale. The flash menu is feeded with >>>> special pages >>>> that resets the persitent locale ... and redirects to the actial page. >>>> >>>> Shit this seems messy ... >>>> >>>> Thanks for the help anyway! >>>> >>>> /Gunnar >>>> >>>> @SetupRender >>>> void setupComponent() >>>> { >>>> if (!userExists) { >>>> username = messages.get("username"); >>>> password = messages.get("password"); >>>> } else { >>>> username = user.getUsername(); >>>> password = messages.get("password"); >>>> } >>>> >>>> language = currentLocale.getLanguage(); >>>> >>>> log.debug(LOGPRE + "1: >>>> TellLayout.setupComponent(currentLocale.language=" + language + ")"); >>>> if ((null == state.getLocale()) && (language != null)) { >>>> state.setLocale(new Locale(language)); >>>> log.debug(LOGPRE + "2: TellLayout.setupComponent(state.locale >>>> initiated to " + state.getLocale() + ")"); >>>> } >>>> >>>> if (!persistentLocale.isSet()) { >>>> persistentLocale.set(state.getLocale()); >>>> log.debug(LOGPRE + "3: >>>> TellLayout.setupComponent(persistentLocale.set(" + persistentLocale.get() + >>>> ")"); >>>> } else { >>>> log.debug(LOGPRE + "4: >>>> TellLayout.setupComponent(persistentLocale=" + persistentLocale.get() + >>>> ")"); >>>> } >>>> >>>> // -- Localize account menu texts. -- >>>> createAccountMenu(); >>>> >>>> } >>>> >>>> >>>> 2009/10/30 cordenier christophe <christophe.corden...@gmail.com> >>>> >>>>> To what corresponds exactly this logs in your rendering scenario ? >>>>> >>>>> [DEBUG] components.TellLayout <<< --- TELLGAMING --- >>>: 1: >>>>> TellLayout.setupComponent( >>>>> currentLocale.language=sv) >>>>> [DEBUG] components.TellLayout <<< --- TELLGAMING --- >>>: 4: >>>>> TellLayout.setupComponent(persistentLocale=en) >>>>> >>>>> >>>>> 2009/10/30 cordenier christophe <christophe.corden...@gmail.com> >>>>> >>>>>> Sorry i have missed >>>>>> >>>>>> [DEBUG] AppModule. >>>>>> ProtectedPageGateKeeper PPGK.path=/en/tellfriends >>>>>> >>>>>> >>>>>> 2009/10/30 Gunnar Eketrapp <gunnar.eketr...@gmail.com> >>>>>> >>>>>>> Hi! >>>>>>> >>>>>>> Well I have read that page over and over ... >>>>>>> >>>>>>> I am calling persistentLocale.set() in the action link connected to >>>>> my >>>>>>> language selector. >>>>>>> >>>>>>> But for some reasons the persistentLocale is not used when rendering >>>>> .... >>>>>>> >>>>>>> The page below is rendered in swedish even if the persistentLocale is >>>>>>> english. >>>>>>> >>>>>>> [DEBUG] AppModule.ProtectedPageGateKeeper PPGK.path=/en/tellfriends >>>>>>> [DEBUG] components.TellLayout <<< --- TELLGAMING --- >>>: 1: >>>>>>> TellLayout.setupComponent(currentLocale.language=sv) >>>>>>> [DEBUG] components.TellLayout <<< --- TELLGAMING --- >>>: 4: >>>>>>> TellLayout.setupComponent(persistentLocale=en) >>>>>>> >>>>>>> >>>>>>> To this I have ... >>>>>>> >>>>>>> TellFriends_en.properties >>>>>>> TellFriends_sv.properties >>>>>>> >>>>>>> ... and "sv" is the default language. >>>>>>> >>>>>>> /Gunnar >>>>>>> >>>>>>> 2009/10/30 cordenier christophe <christophe.corden...@gmail.com> >>>>>>> >>>>>>>> Hi >>>>>>>> >>>>>>>> Have a look at 'Changing the Locale' here >>>>>>>> http://tapestry.apache.org/tapestry5.1/guide/localization.html >>>>>>>> to check if your are using the good scenario to change locale, >>>>> since >>>>>>>> Tapestry 5.1 uses URL to store Local and not a cookie (like in >>>>> 5.0.18) >>>>>>>> >>>>>>>> Christophe. >>>>>>>> >>>>>>>> 2009/10/30 Gunnar Eketrapp <gunnar.eketr...@gmail.com> >>>>>>>> >>>>>>>>> Hi! >>>>>>>>> >>>>>>>>> For some reason my pages are rendered accoring to currentLocale >>>>> and >>>>>>> not >>>>>>>>> persistentLocale. >>>>>>>>> >>>>>>>>> Is there something I should now? >>>>>>>>> >>>>>>>>> Thanks in advance, >>>>>>>>> Gunnar Eketrapp >>>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> [Hem: 08-715 59 57, Mobil: 0708-52 62 90] >>>>>>> Allévägen 2A, 132 42 Saltsjö-Boo >>>>>>> >>>>>> >>>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> [Hem: 08-715 59 57, Mobil: 0708-52 62 90] >>>> Allévägen 2A, 132 42 Saltsjö-Boo >>>> >>> >>> >>> >>> -- >>> [Hem: 08-715 59 57, Mobil: 0708-52 62 90] >>> Allévägen 2A, 132 42 Saltsjö-Boo >>> >> >> >> >> -- >> [Hem: 08-715 59 57, Mobil: 0708-52 62 90] >> Allévägen 2A, 132 42 Saltsjö-Boo >> > > > > -- > [Hem: 08-715 59 57, Mobil: 0708-52 62 90] > Allévägen 2A, 132 42 Saltsjö-Boo
smime.p7s
Description: S/MIME cryptographic signature