You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Chris Merrill <ch...@webperformance.com> on 2012/01/30 22:19:54 UTC

DateTimeField getting the wrong timezone

I'm using the yui.calendar.DateTimeField widget on a page with some other
timezone sensitive data and I get the right timezone on the other fields
but not with DateTimeField.  When I stepped into the DateTimeField code,
I came to line 417:

			TimeZone zone = getClientTimeZone();
which takes me to:

	protected TimeZone getClientTimeZone()
	{
		ClientInfo info = Session.get().getClientInfo();
		if (info instanceof WebClientInfo)
		{
			return ((WebClientInfo)info).getProperties().getTimeZone();
		}
		return null;
	}

This method is returning null via this line:
			return ((WebClientInfo)info).getProperties().getTimeZone();
All the properties in the ClientInfo appear to be defaults.


Now, I'm doing pretty much the same thing in my session, where I'm caching
the timezone (our base page checks the timezone via the session, so this
happens when new sessions are established).

    public TimeZone getTimeZone()
        {
        if (_timezone == null)
            {
            _timezone = getClientInfo().getProperties().getTimeZone();
            if (_timezone == null)
                _timezone = TimeZone.getTimeZone("US/Eastern");
            }
        return _timezone;
        }

This part works fine - all the pages that need the timezone get it and render
date/times correctly.

I was able to easily work around this by subclassing DateTimeField and pushing
in the timezone manually - but I'm wondering what I'm doing wrong that is causing
the timezone to break in DateTimeField?  (I'm assuming this works for everyone
else but me).

Any ideas?

TIA!
Chris



-- 
------------------------------------------------------------------------ -
Chris Merrill                           |  Web Performance, Inc.
chris@webperformance.com                |  http://webperformance.com
919-433-1762                            |  919-845-7601

Web Performance: Website Load Testing Software & Services
------------------------------------------------------------------------ -

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


Re: DateTimeField getting the wrong timezone

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

On Mon, Jan 30, 2012 at 11:27 PM, Chris Merrill
<ch...@webperformance.com> wrote:
> I should add another strange detail to this - the DateTimeField works correctly if I
> establish a new browser eb session within the debug session.  I'm working on AppEngine
> and the SDK will save the session states when it shuts down. When I start a new
> debug session, my existing browser session resumes where I left off and DateTimeField
> gets a null TimeZone. When I logout and log back in, it is then fine.
>
> Could this be AppEngine related?  Could it be that I'm getting the right timezone
> because it is in my session and therefore cached, but the ClientInfo is not?
> Shouldn't the ClientInfo be re-requested automagically from the browser if it isn't
> in the session?

ClientInfo by default contains just the basic information extracted
from User-Agent header.
You need to use
org.apache.wicket.settings.IRequestCycleSettings#setGatherExtendedBrowserInfo(true)
to get more details about the client.
See for example http://www.wicket-library.com/wicket-examples/hellobrowser/
>
> TIA!
> Chris
>
>
> On 1/30/2012 4:19 PM, Chris Merrill wrote:
>> I'm using the yui.calendar.DateTimeField widget on a page with some other
>> timezone sensitive data and I get the right timezone on the other fields
>> but not with DateTimeField.  When I stepped into the DateTimeField code,
>> I came to line 417:
>>
>>                       TimeZone zone = getClientTimeZone();
>> which takes me to:
>>
>>       protected TimeZone getClientTimeZone()
>>       {
>>               ClientInfo info = Session.get().getClientInfo();
>>               if (info instanceof WebClientInfo)
>>               {
>>                       return ((WebClientInfo)info).getProperties().getTimeZone();
>>               }
>>               return null;
>>       }
>>
>> This method is returning null via this line:
>>                       return ((WebClientInfo)info).getProperties().getTimeZone();
>> All the properties in the ClientInfo appear to be defaults.
>>
>>
>> Now, I'm doing pretty much the same thing in my session, where I'm caching
>> the timezone (our base page checks the timezone via the session, so this
>> happens when new sessions are established).
>>
>>     public TimeZone getTimeZone()
>>         {
>>         if (_timezone == null)
>>             {
>>             _timezone = getClientInfo().getProperties().getTimeZone();
>>             if (_timezone == null)
>>                 _timezone = TimeZone.getTimeZone("US/Eastern");
>>             }
>>         return _timezone;
>>         }
>>
>> This part works fine - all the pages that need the timezone get it and render
>> date/times correctly.
>>
>> I was able to easily work around this by subclassing DateTimeField and pushing
>> in the timezone manually - but I'm wondering what I'm doing wrong that is causing
>> the timezone to break in DateTimeField?  (I'm assuming this works for everyone
>> else but me).
>>
>> Any ideas?
>>
>> TIA!
>> Chris
>>
>>
>>
>
>
> --
> ------------------------------------------------------------------------ -
> Chris Merrill                           |  Web Performance, Inc.
> chris@webperformance.com                |  http://webperformance.com
> 919-433-1762                            |  919-845-7601
>
> Web Performance: Website Load Testing Software & Services
> ------------------------------------------------------------------------ -
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: DateTimeField getting the wrong timezone

Posted by Chris Merrill <ch...@webperformance.com>.
I should add another strange detail to this - the DateTimeField works correctly if I
establish a new browser eb session within the debug session.  I'm working on AppEngine
and the SDK will save the session states when it shuts down. When I start a new
debug session, my existing browser session resumes where I left off and DateTimeField
gets a null TimeZone. When I logout and log back in, it is then fine.

Could this be AppEngine related?  Could it be that I'm getting the right timezone
because it is in my session and therefore cached, but the ClientInfo is not?
Shouldn't the ClientInfo be re-requested automagically from the browser if it isn't
in the session?

TIA!
Chris


On 1/30/2012 4:19 PM, Chris Merrill wrote:
> I'm using the yui.calendar.DateTimeField widget on a page with some other
> timezone sensitive data and I get the right timezone on the other fields
> but not with DateTimeField.  When I stepped into the DateTimeField code,
> I came to line 417:
> 
> 			TimeZone zone = getClientTimeZone();
> which takes me to:
> 
> 	protected TimeZone getClientTimeZone()
> 	{
> 		ClientInfo info = Session.get().getClientInfo();
> 		if (info instanceof WebClientInfo)
> 		{
> 			return ((WebClientInfo)info).getProperties().getTimeZone();
> 		}
> 		return null;
> 	}
> 
> This method is returning null via this line:
> 			return ((WebClientInfo)info).getProperties().getTimeZone();
> All the properties in the ClientInfo appear to be defaults.
> 
> 
> Now, I'm doing pretty much the same thing in my session, where I'm caching
> the timezone (our base page checks the timezone via the session, so this
> happens when new sessions are established).
> 
>     public TimeZone getTimeZone()
>         {
>         if (_timezone == null)
>             {
>             _timezone = getClientInfo().getProperties().getTimeZone();
>             if (_timezone == null)
>                 _timezone = TimeZone.getTimeZone("US/Eastern");
>             }
>         return _timezone;
>         }
> 
> This part works fine - all the pages that need the timezone get it and render
> date/times correctly.
> 
> I was able to easily work around this by subclassing DateTimeField and pushing
> in the timezone manually - but I'm wondering what I'm doing wrong that is causing
> the timezone to break in DateTimeField?  (I'm assuming this works for everyone
> else but me).
> 
> Any ideas?
> 
> TIA!
> Chris
> 
> 
> 


-- 
------------------------------------------------------------------------ -
Chris Merrill                           |  Web Performance, Inc.
chris@webperformance.com                |  http://webperformance.com
919-433-1762                            |  919-845-7601

Web Performance: Website Load Testing Software & Services
------------------------------------------------------------------------ -

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