You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by iwanj <iw...@hotmail.com> on 2008/02/01 17:19:58 UTC

setting session locale to browser locale on onSubmit()

this is my second day using wicket from struts/springmvc and I need wicket to
set up so that every request (maybe this is an old thinking?) must follow
the browser's locale.  for pages, I could easily enough to have a base page
and in its contructor do the following:

     Locale locale = getRequest().getLocale();
     locale = doSomething( locale );  // e.g. substituting non-supported
locale
     getSession().setLocale( locale );

and this works fine.  however, for button's onSubmit() wicket uses the
existing page instead of creating a new one and so my code in the base page
constructor's is not run.  copying my code into every handler is one option. 
subclassing all such components is another.  neither seems particularly
appealing for me.

I've looked at replacing standard classes (session, etc.) or overriding some
WebApplication methods, even subsclassing the WicketFilter itself, but I
still couldn't find a place where I have both the session & request objects
to do the locale setting.  being newbie, I probably missed reading some docs
somewhere or some posts in this forum (searched "locale", "request", etc.)

thanks for any help enlightening me on this hurdle.

iwanj
-- 
View this message in context: http://www.nabble.com/setting-session-locale-to-browser-locale-on-onSubmit%28%29-tp15229868p15229868.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: localization of PageExpiredErrorPage.html

Posted by Igor Vaynberg <ig...@gmail.com>.
you can set your own page in page settings

application.init() { getpagesettngs().... }

or maybe its getapplicationsettings()....dont remember off the top of my head.

-igor


On Feb 1, 2008 10:24 PM, Maris Orbidans <sm...@ime.lv> wrote:
>
> Is it possible to localize session expiration error page ?
>
> Error messages are hardcoded in PageExpiredErrorPage.html.
>
>
> Maris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: localization of PageExpiredErrorPage.html

Posted by Edvin Syse <ed...@sysedata.no>.
> Is it possible to localize session expiration error page ?
> Error messages are hardcoded in PageExpiredErrorPage.html.

In your init() method of the application-class you can go:

getApplicationSettings().setPageExpiredErrorPage(YourClass.class);

.. and then create YourClass_lang.html pages for it.

-- Edvin

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


localization of PageExpiredErrorPage.html

Posted by Maris Orbidans <sm...@ime.lv>.
Is it possible to localize session expiration error page ?

Error messages are hardcoded in PageExpiredErrorPage.html. 


Maris

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setting session locale to browser locale on onSubmit()

Posted by iwanj <iw...@hotmail.com>.
thanks, Igor.  your advice is exactly what I was looking for.  I tested all
is working with correct locale.  hopefully when I start using ajax stuff
this will still be true (believe it will).


igor.vaynberg wrote:
> 
> subclass webrequestcycle and add this code into onbeginrequest()
> 
> Locale locale = getRequest().getLocale();
>     locale = doSomething( locale );  // e.g. substituting non-supported
> locale
>     getSession().setLocale( locale );
> 
> see webapplication.newrequestcycle()
> 
> -igor
> 
> 
> 
> On Feb 1, 2008 9:21 AM, iwanj <iw...@hotmail.com> wrote:
>>
>> the post I read was about setting locale upon new session.  just for
>> background, the scenario
>> is displaying certain information/paragraph on different languages.  I
>> could
>> set up the locale
>> button however myh preference is not to have too long a list of supported
>> locale, certain users
>> might only use 2-3 locales, but overal could be many.  also, my
>> preference
>> is not to maintain
>> too many different sets of html pages (locale-wise, so same reason with
>> button).  on the project
>> I had set up my own string resource loader, so that I only have one
>> properties file per locale, instead
>> of for every page/class.  with my not-too-appealing method described in
>> original post, a user could
>> simply switch the browser locale and hit refresh button (or other buttons
>> on
>> the page, example: page
>> is in english, user enter 優しい時間 in japanese, switch browser language to
>> japanese, and hit "Find" button) and the page will be
>> displayed/redisplayed
>> using the new locale, what I'm looking is for way to avoid putting the
>> same
>> code on various component's event handler codes.  thanks for the
>> suggestion,
>> though.
>>
>>
>>
>> Nino.Martinez wrote:
>> >
>> > Hmm, I though this was done already... Or might only be upon initiation
>> > of session?
>> >
>> > What would be the motivation for the user changing locale mid session?
>> > Otherwise i'd suggest having a button changing sessions locale.. This
>> > has worked for me in the past... Although you might want to use
>> > stringressource models.. I remember some issue but that was in beta4...
>> >
>> > iwanj wrote:
>> >> this is my second day using wicket from struts/springmvc and I need
>> >> wicket to
>> >> set up so that every request (maybe this is an old thinking?) must
>> follow
>> >> the browser's locale.  for pages, I could easily enough to have a base
>> >> page
>> >> and in its contructor do the following:
>> >>
>> >>      Locale locale = getRequest().getLocale();
>> >>      locale = doSomething( locale );  // e.g. substituting
>> non-supported
>> >> locale
>> >>      getSession().setLocale( locale );
>> >>
>> >> and this works fine.  however, for button's onSubmit() wicket uses the
>> >> existing page instead of creating a new one and so my code in the base
>> >> page
>> >> constructor's is not run.  copying my code into every handler is one
>> >> option.
>> >> subclassing all such components is another.  neither seems
>> particularly
>> >> appealing for me.
>> >>
>> >> I've looked at replacing standard classes (session, etc.) or
>> overriding
>> >> some
>> >> WebApplication methods, even subsclassing the WicketFilter itself, but
>> I
>> >> still couldn't find a place where I have both the session & request
>> >> objects
>> >> to do the locale setting.  being newbie, I probably missed reading
>> some
>> >> docs
>> >> somewhere or some posts in this forum (searched "locale", "request",
>> >> etc.)
>> >>
>> >> thanks for any help enlightening me on this hurdle.
>> >>
>> >> iwanj
>> >>
>> >
>> > --
>> > Nino Martinez Wael
>> > Java Specialist @ Jayway DK
>> > http://www.jayway.dk
>> > +45 2936 7684
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/setting-session-locale-to-browser-locale-on-onSubmit%28%29-tp15229868p15231373.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>>
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/setting-session-locale-to-browser-locale-on-onSubmit%28%29-tp15229868p15231837.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setting session locale to browser locale on onSubmit()

Posted by Igor Vaynberg <ig...@gmail.com>.
subclass webrequestcycle and add this code into onbeginrequest()

Locale locale = getRequest().getLocale();
    locale = doSomething( locale );  // e.g. substituting non-supported
locale
    getSession().setLocale( locale );

see webapplication.newrequestcycle()

-igor



On Feb 1, 2008 9:21 AM, iwanj <iw...@hotmail.com> wrote:
>
> the post I read was about setting locale upon new session.  just for
> background, the scenario
> is displaying certain information/paragraph on different languages.  I could
> set up the locale
> button however myh preference is not to have too long a list of supported
> locale, certain users
> might only use 2-3 locales, but overal could be many.  also, my preference
> is not to maintain
> too many different sets of html pages (locale-wise, so same reason with
> button).  on the project
> I had set up my own string resource loader, so that I only have one
> properties file per locale, instead
> of for every page/class.  with my not-too-appealing method described in
> original post, a user could
> simply switch the browser locale and hit refresh button (or other buttons on
> the page, example: page
> is in english, user enter 優しい時間 in japanese, switch browser language to
> japanese, and hit "Find" button) and the page will be displayed/redisplayed
> using the new locale, what I'm looking is for way to avoid putting the same
> code on various component's event handler codes.  thanks for the suggestion,
> though.
>
>
>
> Nino.Martinez wrote:
> >
> > Hmm, I though this was done already... Or might only be upon initiation
> > of session?
> >
> > What would be the motivation for the user changing locale mid session?
> > Otherwise i'd suggest having a button changing sessions locale.. This
> > has worked for me in the past... Although you might want to use
> > stringressource models.. I remember some issue but that was in beta4...
> >
> > iwanj wrote:
> >> this is my second day using wicket from struts/springmvc and I need
> >> wicket to
> >> set up so that every request (maybe this is an old thinking?) must follow
> >> the browser's locale.  for pages, I could easily enough to have a base
> >> page
> >> and in its contructor do the following:
> >>
> >>      Locale locale = getRequest().getLocale();
> >>      locale = doSomething( locale );  // e.g. substituting non-supported
> >> locale
> >>      getSession().setLocale( locale );
> >>
> >> and this works fine.  however, for button's onSubmit() wicket uses the
> >> existing page instead of creating a new one and so my code in the base
> >> page
> >> constructor's is not run.  copying my code into every handler is one
> >> option.
> >> subclassing all such components is another.  neither seems particularly
> >> appealing for me.
> >>
> >> I've looked at replacing standard classes (session, etc.) or overriding
> >> some
> >> WebApplication methods, even subsclassing the WicketFilter itself, but I
> >> still couldn't find a place where I have both the session & request
> >> objects
> >> to do the locale setting.  being newbie, I probably missed reading some
> >> docs
> >> somewhere or some posts in this forum (searched "locale", "request",
> >> etc.)
> >>
> >> thanks for any help enlightening me on this hurdle.
> >>
> >> iwanj
> >>
> >
> > --
> > Nino Martinez Wael
> > Java Specialist @ Jayway DK
> > http://www.jayway.dk
> > +45 2936 7684
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/setting-session-locale-to-browser-locale-on-onSubmit%28%29-tp15229868p15231373.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
>
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setting session locale to browser locale on onSubmit()

Posted by iwanj <iw...@hotmail.com>.
the post I read was about setting locale upon new session.  just for
background, the scenario
is displaying certain information/paragraph on different languages.  I could
set up the locale
button however myh preference is not to have too long a list of supported
locale, certain users
might only use 2-3 locales, but overal could be many.  also, my preference
is not to maintain
too many different sets of html pages (locale-wise, so same reason with
button).  on the project
I had set up my own string resource loader, so that I only have one
properties file per locale, instead
of for every page/class.  with my not-too-appealing method described in
original post, a user could
simply switch the browser locale and hit refresh button (or other buttons on
the page, example: page
is in english, user enter 優しい時間 in japanese, switch browser language to
japanese, and hit "Find" button) and the page will be displayed/redisplayed
using the new locale, what I'm looking is for way to avoid putting the same
code on various component's event handler codes.  thanks for the suggestion,
though.


Nino.Martinez wrote:
> 
> Hmm, I though this was done already... Or might only be upon initiation 
> of session?
> 
> What would be the motivation for the user changing locale mid session? 
> Otherwise i'd suggest having a button changing sessions locale.. This 
> has worked for me in the past... Although you might want to use 
> stringressource models.. I remember some issue but that was in beta4...
> 
> iwanj wrote:
>> this is my second day using wicket from struts/springmvc and I need
>> wicket to
>> set up so that every request (maybe this is an old thinking?) must follow
>> the browser's locale.  for pages, I could easily enough to have a base
>> page
>> and in its contructor do the following:
>>
>>      Locale locale = getRequest().getLocale();
>>      locale = doSomething( locale );  // e.g. substituting non-supported
>> locale
>>      getSession().setLocale( locale );
>>
>> and this works fine.  however, for button's onSubmit() wicket uses the
>> existing page instead of creating a new one and so my code in the base
>> page
>> constructor's is not run.  copying my code into every handler is one
>> option. 
>> subclassing all such components is another.  neither seems particularly
>> appealing for me.
>>
>> I've looked at replacing standard classes (session, etc.) or overriding
>> some
>> WebApplication methods, even subsclassing the WicketFilter itself, but I
>> still couldn't find a place where I have both the session & request
>> objects
>> to do the locale setting.  being newbie, I probably missed reading some
>> docs
>> somewhere or some posts in this forum (searched "locale", "request",
>> etc.)
>>
>> thanks for any help enlightening me on this hurdle.
>>
>> iwanj
>>   
> 
> -- 
> Nino Martinez Wael
> Java Specialist @ Jayway DK
> http://www.jayway.dk
> +45 2936 7684
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/setting-session-locale-to-browser-locale-on-onSubmit%28%29-tp15229868p15231373.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setting session locale to browser locale on onSubmit()

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
Hmm, I though this was done already... Or might only be upon initiation 
of session?

What would be the motivation for the user changing locale mid session? 
Otherwise i'd suggest having a button changing sessions locale.. This 
has worked for me in the past... Although you might want to use 
stringressource models.. I remember some issue but that was in beta4...

iwanj wrote:
> this is my second day using wicket from struts/springmvc and I need wicket to
> set up so that every request (maybe this is an old thinking?) must follow
> the browser's locale.  for pages, I could easily enough to have a base page
> and in its contructor do the following:
>
>      Locale locale = getRequest().getLocale();
>      locale = doSomething( locale );  // e.g. substituting non-supported
> locale
>      getSession().setLocale( locale );
>
> and this works fine.  however, for button's onSubmit() wicket uses the
> existing page instead of creating a new one and so my code in the base page
> constructor's is not run.  copying my code into every handler is one option. 
> subclassing all such components is another.  neither seems particularly
> appealing for me.
>
> I've looked at replacing standard classes (session, etc.) or overriding some
> WebApplication methods, even subsclassing the WicketFilter itself, but I
> still couldn't find a place where I have both the session & request objects
> to do the locale setting.  being newbie, I probably missed reading some docs
> somewhere or some posts in this forum (searched "locale", "request", etc.)
>
> thanks for any help enlightening me on this hurdle.
>
> iwanj
>   

-- 
Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setting session locale to browser locale on onSubmit()

Posted by Edward Yakop <ed...@gmail.com>.
On Feb 2, 2008 12:19 AM, iwanj <iw...@hotmail.com> wrote:
> and this works fine.  however, for button's onSubmit() wicket uses the
> existing page instead of creating a new one and so my code in the base page
> constructor's is not run.  copying my code into every handler is one option.
> subclassing all such components is another.  neither seems particularly
> appealing for me.
What exactly do you want to do with the locale information?

If u want internationalize the page,
You could either always do.
<PageClassName>_<locale>.html
or
<PanelClassName>_<locale>.html
or
If they're in resource bundle.properties, you could always do
new Label( "wicketId", new ResourceModel( "resourceBundleKey" ) );

Or otherwise
If this is mass changes of components etcs
setResponsePage( new PageClassToInstantiate() );

Regards,
Edward Yakop

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org