Re: WebObjects 5.3.3, DST and J2SE 1.4.2, parse javascript help
Re: WebObjects 5.3.3, DST and J2SE 1.4.2, parse javascript help
- Subject: Re: WebObjects 5.3.3, DST and J2SE 1.4.2, parse javascript help
- From: Wilson Lee <email@hidden>
- Date: Thu, 8 Mar 2007 16:39:44 -0500
Option 1, put the document.write inside of your form component.
You'll see the value in the request and won't need the WOHiddenField.
<head>
<script language=javascript>
var now = new Date();
var clientTimeZoneOffset = now.getTimezoneOffset();
</script>
</head>
...
<webobject name=Form1>
document.write('<input type="hidden" name="xClientTimeZoneOffset"
value="' + clientTimeZoneOffset * 60 * -1 + '" />');
...
</webobject>
Option2, if you want to use the WOHiddenField, you'll need to copy
clientTimeZoneOffset to the hidden field while using the body onload
handler.
<head>
<script language=javascript>
var now = new Date();
var clientTimeZoneOffset = now.getTimezoneOffset();
function setXClientTimeZoneOffset() {
document.yourFormName.xClientTimeZoneOffset.value =
clientTimeZoneOffset * 60 * -1;
}
</script>
</head>
<body onload="setXClientTimeZoneOffset();">
...
When I verified the above, WOBuilder wouldn't let me leave source
view when the WOHiddenField was named with a dash, and I couldn't set
the value of the hidden field in javascript when it was named with a
dash. So I guess it's bad to use dashes in your wo/form component
names.
-Wilson
On Mar 8, 2007, at 1:49 PM, Baiss Eric Magnusson wrote:
I'm working with your below code, many thanks.
The part that has stumped me is <that grabs the timezone from the
header>
I create a WOHiddenField in the WOForm, ( I do know the javascript
is loading and being called )
HiddenFld_TimeZone: WOHiddenField {
name = "x-clientTimeZoneOffset";
value = timeZoneJS;
}
<p><webobject name="HiddenFld_TimeZone"></webobject></p>
String timeZoneJS;
But I look at the request field and the <value> of the name <x-
clientTimeZoneOffset> is "".
If I remove the Hidden field nothing is written into the
(WORequest> from the line
document.write('<input type="hidden" name="x-
clientTimeZoneOffset" value="' + clientTimeZoneOffset * 60 * -1 +
'" />');
I guess the simple question is, how do I get the value into the
java from the javascript line below?
On Mar 7, 2007, at 8:48 AM, Ken Anderson wrote:
On Mar 7, 2007, at 11:34 AM, Baiss Eric Magnusson wrote:
I've been gathering this response, but Ken has been so helpful
and right on with his comments that I thought I should reply.
I have work to do. I will have to create the UI to get the
timezone, store the timezone in the database, and use it in the
various date displays.
Other comments below.
Thanks. One thing you might consider is using this javascript:
// This code lifted from 'http://www.mkolar.org/javascript/
clock.html' and liberally modified
var now = new Date();
var clientTimeZoneOffset = now.getTimezoneOffset();
if (clientTimeZoneOffset) {
document.write('<input type="hidden" name="x-
clientTimeZoneOffset" value="' + clientTimeZoneOffset * 60 * -1 +
'" />');
}
It creates a header that specifies the timezone as the client
machine sees it. I drop this javascript into a WO component that
grabs the timezone from the header and sets it in the user's session.
Ken
----
Baiss Eric Magnusson
<http://www.Track-Your-Finances.com>
<http://www.CascadeWebDesign.com>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >WebObjects 5.3.3, DST and J2SE 1.4.2 (From: Baiss Eric Magnusson <email@hidden>) |
| >Re: WebObjects 5.3.3, DST and J2SE 1.4.2 (From: Pascal Robert <email@hidden>) |
| >Re: WebObjects 5.3.3, DST and J2SE 1.4.2 (From: Baiss Eric Magnusson <email@hidden>) |
| >Re: WebObjects 5.3.3, DST and J2SE 1.4.2 (From: Ken Anderson <email@hidden>) |
| >Re: WebObjects 5.3.3, DST and J2SE 1.4.2 (From: Baiss Eric Magnusson <email@hidden>) |
| >Re: WebObjects 5.3.3, DST and J2SE 1.4.2 (From: Chuck Hill <email@hidden>) |
| >Re: WebObjects 5.3.3, DST and J2SE 1.4.2 (From: Baiss Eric Magnusson <email@hidden>) |
| >Re: WebObjects 5.3.3, DST and J2SE 1.4.2 (From: Ken Anderson <email@hidden>) |
| >Re: WebObjects 5.3.3, DST and J2SE 1.4.2, parse javascript help (From: Baiss Eric Magnusson <email@hidden>) |