You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Tauren Mills <ta...@groovee.com> on 2011/11/27 23:07:57 UTC

Where to best configure user timezone?

Where is the recommended place to configure the timezone for a user? My
user object has a timezone setting that the user can control
(Member.timezone). The following code seems to work and configure all of
the Wicket components to use the user's timezone:

ClientInfo ci = Session.get().getClientInfo();
((WebClientInfo)ci
).getProperties().setTimeZone(TimeZone.getTimeZone(member.getTimezone()));

However, I'm not sure where the best place to put this code would be.
Should it be on each page? In the Session constructor? Somewhere else?

I was thinking that the Session constructor would be best, but if the
session is created before the user logs in and authenticates, then it won't
get set properly. I can include the code again in my Session.login method.
But is there somewhere else that would be better?

Thanks!
Tauren

Re: Where to best configure user timezone?

Posted by Tauren Mills <ta...@groovee.com>.
Igor,

Since I'm also using remember-me cookie-based authentication via Shiro,
Session.login may not always be run. But doing this in both the session
constructor and in session.login does the trick.

Thanks for your help!

Tauren


On Sun, Nov 27, 2011 at 3:05 PM, Igor Vaynberg <ig...@gmail.com>wrote:

> session.login should be good...
>
> -igor
>
> On Sun, Nov 27, 2011 at 2:07 PM, Tauren Mills <ta...@groovee.com> wrote:
> > Where is the recommended place to configure the timezone for a user? My
> > user object has a timezone setting that the user can control
> > (Member.timezone). The following code seems to work and configure all of
> > the Wicket components to use the user's timezone:
> >
> > ClientInfo ci = Session.get().getClientInfo();
> > ((WebClientInfo)ci
> >
> ).getProperties().setTimeZone(TimeZone.getTimeZone(member.getTimezone()));
> >
> > However, I'm not sure where the best place to put this code would be.
> > Should it be on each page? In the Session constructor? Somewhere else?
> >
> > I was thinking that the Session constructor would be best, but if the
> > session is created before the user logs in and authenticates, then it
> won't
> > get set properly. I can include the code again in my Session.login
> method.
> > But is there somewhere else that would be better?
> >
> > Thanks!
> > Tauren
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Where to best configure user timezone?

Posted by Igor Vaynberg <ig...@gmail.com>.
session.login should be good...

-igor

On Sun, Nov 27, 2011 at 2:07 PM, Tauren Mills <ta...@groovee.com> wrote:
> Where is the recommended place to configure the timezone for a user? My
> user object has a timezone setting that the user can control
> (Member.timezone). The following code seems to work and configure all of
> the Wicket components to use the user's timezone:
>
> ClientInfo ci = Session.get().getClientInfo();
> ((WebClientInfo)ci
> ).getProperties().setTimeZone(TimeZone.getTimeZone(member.getTimezone()));
>
> However, I'm not sure where the best place to put this code would be.
> Should it be on each page? In the Session constructor? Somewhere else?
>
> I was thinking that the Session constructor would be best, but if the
> session is created before the user logs in and authenticates, then it won't
> get set properly. I can include the code again in my Session.login method.
> But is there somewhere else that would be better?
>
> Thanks!
> Tauren
>

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