You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Programozás <pr...@hotmail.com> on 2004/03/07 15:38:13 UTC

changing locale

Hello,

I'd like to change the locale in a listener of a component:

public void onEn(IRequestCycle cycle)
{
    getPage().getEngine().setLocale(new Locale("en"));
    throw new PageRedirectException(getPage().getExtendedId());
}

But it's not working. What else should I do to change the locale
immediately?

Thanks,
Norbi

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: changing locale

Posted by Mindbridge <mi...@yahoo.com>.
Hi,

I haven't received Norbi's email, but can probably add to this a bit. What
you are discussing essentially involves a client-side redirect. That
definitely works.

To avoid the extra round trip when changing the locale, however, you can do
something like this:

public void onEn(IRequestCycle cycle)
{
    getPage().getEngine().setLocale(new Locale("en"));
    getPage().getRequestCycle().cleanup();
    throw new PageRedirectException(getPage().getExtendedId());
}

(notice the extra second line -- I think that's what you were missing)

This should change the locale and load the same page again, but this time
with the new locale. The action will be performed on the server-side only.

I guess this should probably go into the Wiki (assuming it is not too big of
hack)

-mb

----- Original Message ----- 
From: "Erik Hatcher" <er...@ehatchersolutions.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Sunday, March 07, 2004 5:01 PM
Subject: Re: changing locale


One option that should definitely work is to throw RedirectException
with a full URL, not just a relative one.

Paul Ferraro posted a nice addition to RedirectException that makes it
cleaner to truly redirect to a page.

Erik

On Mar 7, 2004, at 9:38 AM, Programozás wrote:

> Hello,
>
> I'd like to change the locale in a listener of a component:
>
> public void onEn(IRequestCycle cycle)
> {
>     getPage().getEngine().setLocale(new Locale("en"));
>     throw new PageRedirectException(getPage().getExtendedId());
> }
>
> But it's not working. What else should I do to change the locale
> immediately?
>
> Thanks,
> Norbi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: changing locale

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
One thing we should encourage folks to do when solutions to common 
issues are found, is to post them on the Tapestry wiki.

So, if you could, perhaps post a brief step-by-step at the wiki :)

Thanks,
	Erik

p.s. Paul posted to both tapestry-user and tapestry-dev on this topic, 
with code posted to tapestry-user.

On Mar 7, 2004, at 10:49 AM, Programozás wrote:

> Thanks, it's working. (Altough I was surprised that in the mailing list
> archive I haven't found any mails from Paul Ferraro.)
>
> The only extra thing I had to do is to call getVisit() to force session
> creation before I call getEngine().setLocale().
>
> Norbi
>
>
> ----- Original Message -----
> From: "Erik Hatcher" <er...@ehatchersolutions.com>
> To: "Tapestry users" <ta...@jakarta.apache.org>
> Sent: Sunday, March 07, 2004 4:01 PM
> Subject: Re: changing locale
>
>
> One option that should definitely work is to throw RedirectException
> with a full URL, not just a relative one.
>
> Paul Ferraro posted a nice addition to RedirectException that makes it
> cleaner to truly redirect to a page.
>
> Erik
>
> On Mar 7, 2004, at 9:38 AM, Programozás wrote:
>
>> Hello,
>>
>> I'd like to change the locale in a listener of a component:
>>
>> public void onEn(IRequestCycle cycle)
>> {
>>     getPage().getEngine().setLocale(new Locale("en"));
>>     throw new PageRedirectException(getPage().getExtendedId());
>> }
>>
>> But it's not working. What else should I do to change the locale
>> immediately?
>>
>> Thanks,
>> Norbi
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: changing locale

Posted by Programozás <pr...@hotmail.com>.
Thanks, it's working. (Altough I was surprised that in the mailing list
archive I haven't found any mails from Paul Ferraro.)

The only extra thing I had to do is to call getVisit() to force session
creation before I call getEngine().setLocale().

Norbi


----- Original Message ----- 
From: "Erik Hatcher" <er...@ehatchersolutions.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Sunday, March 07, 2004 4:01 PM
Subject: Re: changing locale


One option that should definitely work is to throw RedirectException
with a full URL, not just a relative one.

Paul Ferraro posted a nice addition to RedirectException that makes it
cleaner to truly redirect to a page.

Erik

On Mar 7, 2004, at 9:38 AM, Programozás wrote:

> Hello,
>
> I'd like to change the locale in a listener of a component:
>
> public void onEn(IRequestCycle cycle)
> {
>     getPage().getEngine().setLocale(new Locale("en"));
>     throw new PageRedirectException(getPage().getExtendedId());
> }
>
> But it's not working. What else should I do to change the locale
> immediately?
>
> Thanks,
> Norbi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: changing locale

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
One option that should definitely work is to throw RedirectException 
with a full URL, not just a relative one.

Paul Ferraro posted a nice addition to RedirectException that makes it 
cleaner to truly redirect to a page.

	Erik

On Mar 7, 2004, at 9:38 AM, Programozás wrote:

> Hello,
>
> I'd like to change the locale in a listener of a component:
>
> public void onEn(IRequestCycle cycle)
> {
>     getPage().getEngine().setLocale(new Locale("en"));
>     throw new PageRedirectException(getPage().getExtendedId());
> }
>
> But it's not working. What else should I do to change the locale
> immediately?
>
> Thanks,
> Norbi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org