Re: T5: Changing locale within OnActivate event
If you build a "shadow service" or similar sort of infrastructure related thing you can always intercept the call before pages are resolved / loaded / etc if you know ahead of time that you are going to want to change the locale in some way. (ie if it's architecture / infrastructure related and not one off pieces of functionality ) On 8/17/07, Doug Hauge <[EMAIL PROTECTED]> wrote: > I was afraid that would be the answer (I couldn't see any other way > after looking at the code). I was wanting to avoid having to add > duplicate redirection logic to each page, but I'll give it a try and see > how it works. Thanks for the response. > > Doug > > > -Original Message- > > From: Jesse Kuhnert [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, August 14, 2007 7:22 PM > > To: Tapestry users > > Subject: Re: T5: Changing locale within OnActivate event > > > > If it's anything like T4 you'll have to either do a redirect back to > > the same page or whatever mechanism is in place to "make a page > > active" somehow and have it do that to the same page. > > > > All the i18n stuff probably happens in the very beginning while > > setting up the page/components/resources so it has to start over if > > you want to change locales. I'm sure you know more than I do about > > redirects/page activations in T5 though. > > > > On 8/14/07, Doug Hauge <[EMAIL PROTECTED]> wrote: > > > In several of our pages, the default locale we want to use for > > messages > > > depends on its activation context. We tried updating the locale > using > > > 'ThreadLocale' from within the activate event handler, but it seems > > that > > > this is too late, for the page has already been loaded and all > > messages > > > in the template resolved using whatever locale was in effect at the > > time > > > of loading. Is there some way we can force the messages to be > > reloaded > > > after setting the thread locale in the activate event handler, or is > > > there some point before the page is loaded at which we can access > the > > > page class and the activation context in order to set the locale? > > > > > > Thanks, > > > Doug > > > > > > > > > > - > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > -- > > Jesse Kuhnert > > Tapestry/Dojo team member/developer > > > > Open source based consulting work centered around > > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com > > > > - > > 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] > > -- Jesse Kuhnert Tapestry/Dojo team member/developer Open source based consulting work centered around dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: T5: Changing locale within OnActivate event
I was afraid that would be the answer (I couldn't see any other way after looking at the code). I was wanting to avoid having to add duplicate redirection logic to each page, but I'll give it a try and see how it works. Thanks for the response. Doug > -Original Message- > From: Jesse Kuhnert [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 14, 2007 7:22 PM > To: Tapestry users > Subject: Re: T5: Changing locale within OnActivate event > > If it's anything like T4 you'll have to either do a redirect back to > the same page or whatever mechanism is in place to "make a page > active" somehow and have it do that to the same page. > > All the i18n stuff probably happens in the very beginning while > setting up the page/components/resources so it has to start over if > you want to change locales. I'm sure you know more than I do about > redirects/page activations in T5 though. > > On 8/14/07, Doug Hauge <[EMAIL PROTECTED]> wrote: > > In several of our pages, the default locale we want to use for > messages > > depends on its activation context. We tried updating the locale using > > 'ThreadLocale' from within the activate event handler, but it seems > that > > this is too late, for the page has already been loaded and all > messages > > in the template resolved using whatever locale was in effect at the > time > > of loading. Is there some way we can force the messages to be > reloaded > > after setting the thread locale in the activate event handler, or is > > there some point before the page is loaded at which we can access the > > page class and the activation context in order to set the locale? > > > > Thanks, > > Doug > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > -- > Jesse Kuhnert > Tapestry/Dojo team member/developer > > Open source based consulting work centered around > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com > > - > 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]
Re: T5: Changing locale within OnActivate event
If it's anything like T4 you'll have to either do a redirect back to the same page or whatever mechanism is in place to "make a page active" somehow and have it do that to the same page. All the i18n stuff probably happens in the very beginning while setting up the page/components/resources so it has to start over if you want to change locales. I'm sure you know more than I do about redirects/page activations in T5 though. On 8/14/07, Doug Hauge <[EMAIL PROTECTED]> wrote: > In several of our pages, the default locale we want to use for messages > depends on its activation context. We tried updating the locale using > 'ThreadLocale' from within the activate event handler, but it seems that > this is too late, for the page has already been loaded and all messages > in the template resolved using whatever locale was in effect at the time > of loading. Is there some way we can force the messages to be reloaded > after setting the thread locale in the activate event handler, or is > there some point before the page is loaded at which we can access the > page class and the activation context in order to set the locale? > > Thanks, > Doug > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Jesse Kuhnert Tapestry/Dojo team member/developer Open source based consulting work centered around dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
T5: Changing locale within OnActivate event
In several of our pages, the default locale we want to use for messages depends on its activation context. We tried updating the locale using 'ThreadLocale' from within the activate event handler, but it seems that this is too late, for the page has already been loaded and all messages in the template resolved using whatever locale was in effect at the time of loading. Is there some way we can force the messages to be reloaded after setting the thread locale in the activate event handler, or is there some point before the page is loaded at which we can access the page class and the activation context in order to set the locale? Thanks, Doug - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5 - Changing Locale
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 > Greek > English > > 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]
Re: T5 - Changing Locale
tapestry version 5.0.4 I have the following code in the html template of my LayoutCmpnt Greek English 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#a10424282 Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5 - Changing Locale
I have the following link in my html tapestry page English and the following method in the corresponding Java Class but it doesn't get called when the above link is clicked @OnEvent(value = "action", component = "englishLocaleLink") Object onActionFromEnglishLocaleLink(@InjectService("ThreadLocale") ThreadLocale threadLocale) { threadLocale.setLocale(new Locale("en")); return null; } If I remove the ThreadLocale parameter the method gets called but obviously the locale is not changed. Is the above the correct way to inject the ThreadLocale service in my page? If yes then how can I force the above method to be called and consequently change the locale. Thanks, 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#a10414090 Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5 - Changing Locale
I've been doing some other things, when I get a chance to try it, I'll share the experience on the list. Bogdan. On 3/20/07, alexvs <[EMAIL PROTECTED]> wrote: Hi Bogdan, Were you ever able to change the locale? Thanks! Alex Bogdan Calmac-4 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] > > > -- View this message in context: http://www.nabble.com/T5---Changing-Locale-tf3376399.html#a9579521 Sent from the Tapestry - User mailing list archive at Nabble.com. - 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]
Re: T5 - Changing Locale
Hi Bogdan, Were you ever able to change the locale? Thanks! Alex Bogdan Calmac-4 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] > > > -- View this message in context: http://www.nabble.com/T5---Changing-Locale-tf3376399.html#a9579521 Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5 - Changing Locale
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]
Re: T5 - Changing Locale
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]
Re: T5 - Changing Locale
hey, did you copy my reply or did i copy yours ? :o) Pablo Ruggia wrote: http://tapestry.apache.org/tapestry5/tapestry-core/guide/localization.html "Tapestry does not yet support changing the locale, but that will be available shortly. The intent is to mimic Tapestry 4 behavior: store a cookie on the client to provide the default for the locale on the next visit, and store a locale name in the session (if a session exists). TODO: I believe this has been implemented by Kent." On 3/9/07, Bogdan Calmac <[EMAIL PROTECTED]> 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]
Re: T5 - Changing Locale
http://tapestry.apache.org/tapestry5/tapestry-core/guide/localization.html "Tapestry does not yet support changing the locale, but that will be available shortly. The intent is to mimic Tapestry 4 behavior: store a cookie on the client to provide the default for the locale on the next visit, and store a locale name in the session (if a session exists). TODO: I believe this has been implemented by Kent." On 3/9/07, Bogdan Calmac <[EMAIL PROTECTED]> 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]
T5 - Changing Locale
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]
Re: T5 - Changing Locale
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]