Your code worked for me, except I replaced ThreadLocale by PersistentLocale
@Inject @Service("PersistentLocale") private PersistentLocale persistentLocaleService; then it works using e.g. persistentLocaleService.set(new Locale("fr")); Karel petros wrote: > > tapestry version 5.0.4 > > I have the following code in the html template of my LayoutCmpnt > <aa t:id="greekLocaleLink" t:type="ActionLink">Greek</aa><br/> > <aa t:id="englishLocaleLink" t:type="ActionLink">English</aa> > > and the following code in the LayoutCmpnt.java > @Inject > @Service("ThreadLocale") > private ThreadLocale threadLocaleService; > > @Inject > private Locale currentLocale; > > @OnEvent(value = "action", component = "greekLocaleLink") > Object onActionFromGreekLocaleLink() > { > threadLocaleService.setLocale(new Locale("el")); > return null; > } > > @OnEvent(value = "action", component = "englishLocaleLink") > Object onActionFromEnglishLocaleLink() > { > threadLocaleService.setLocale(new Locale("en")); > return null; > } > > When the Greek link is clicked the onActionFromGreekLocaleLink() method is > called as expected, but just before the method is returned the > currentLocale object is still set to the "en" Locale. Is this the right > way to change the Locale programmatically ? > > Petros > > > Howard Lewis Ship wrote: >> >> I think that comment is out of date. >> >> You should be able to inject the ThreadLocale service and change the >> locale there. Tapestry will pick up on that and write out an updated >> cookie, which will cause the subsequent render request to be in the >> new locale. >> >> On 3/9/07, Bogdan Calmac <[EMAIL PROTECTED]> wrote: >>> Thanks guys, I saw that, but there was no mention about the ability to >>> change the locale at application level. So I can assume that for my >>> use case I would inject a new service in my page and use it to change >>> the locale programatically? >>> >>> Thanks, >>> >>> Bogdan Calmac. >>> >>> On 3/9/07, Hugo Palma <[EMAIL PROTECTED]> wrote: >>> > Take a look at the bottom of this page >>> > >>> http://tapestry.apache.org/tapestry5/tapestry-core/guide/localization.html. >>> > >>> > /"Tapestry does not yet support changing the locale, but that will be >>> > available shortly."/ >>> > >>> > Bogdan Calmac wrote: >>> > > Is it possible in Tapestry 5 to programatically change the locale >>> for >>> > > a sesison similar to IEngine.setLocale() from Tapestry 4? >>> > > >>> > > In my case I want to set the locale after the login into the >>> > > application (locale is stored in the user profile) and not rely on >>> the >>> > > browser locale. >>> > > >>> > > Thank you, >>> > > >>> > > Bogdan Calmac. >>> > > >>> > > >>> --------------------------------------------------------------------- >>> > > To unsubscribe, e-mail: [EMAIL PROTECTED] >>> > > For additional commands, e-mail: [EMAIL PROTECTED] >>> > > >>> > > >>> > >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>> For additional commands, e-mail: [EMAIL PROTECTED] >>> >>> >> >> >> -- >> Howard M. Lewis Ship >> TWD Consulting, Inc. >> Independent J2EE / Open-Source Java Consultant >> Creator and PMC Chair, Apache Tapestry >> Creator, Apache HiveMind >> >> Professional Tapestry training, mentoring, support >> and project work. http://howardlewisship.com >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> > > -- View this message in context: http://www.nabble.com/T5---Changing-Locale-tf3376399.html#a11489178 Sent from the Tapestry - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]