You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Konstantin <ch...@ukr.net> on 2008/09/29 15:11:36 UTC

Tapestry 5.0.15 DateField localization problem

In new corelib\components\DateField one can find:

    JSONObject onParse()
    {
...
            response.put(RESULT, date.toString());
...
    }

For my timezone it returns: "Mon Sep 01 00:00:00 EEST 2008", but then in
datefield.js it tries:

var resultHandler = function(result)
{
  var date = new Date(result);

date would have Invalid Date value, and the whole calendar popup would show
up ruined.

I tried messing with FireBug in console and it looks like EEST timezone name
is a problem, if I put GMT+3 in it then javascript engine in my FF would
parse that date.

Possible fix would be changing date.toString() to date.getGMTString() -
which is deprecated long time ago.
-- 
View this message in context: http://www.nabble.com/Tapestry-5.0.15-DateField-localization-problem-tp19723586p19723586.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Tapestry 5.0.15 DateField localization problem [patch included]

Posted by Konstantin <ch...@ukr.net>.
Looks as a right fix, in my first post I pointed to the root of this problem,
but I'm too lazy to build Tapestry from sources just for this simple fix.


Mikaël Cluseau-3 wrote:
> 
> Well I still had stability problems under IE (surprise!) so I tried to
> fix the thing in Tapestry itself. AFAIK, it work flowlessly.
> 

-- 
View this message in context: http://www.nabble.com/Tapestry-5.0.15-DateField-localization-problem-tp19723586p19989363.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Tapestry 5.0.15 DateField localization problem [patch included]

Posted by Mikaël Cluseau <mc...@gmail.com>.
I think it should work, but I'm not absolutly sure. Since you can't
select the time zone in the calendar (hopefully!), you may be right to
avoid transfering timezone information, because it could change the day
when going from/to the server to/from the client.

Example.

I'm at GMT+11. If write the following javascript:

var d = new Date("Mon Oct 20 00:00:00 GMT+1200 2008");
document.write("<p>"+d+"</p>");

It gives me:
Sun Oct 19 2008 23:00:00 GMT+1100 (NCT)

While for this javascript:

var d = new Date("Mon Oct 20 00:00:00 2008");
document.write("<p>"+d+"</p>");

I get:
Mon Oct 20 2008 00:00:00 GMT+1100 (NCT)

Given the semantics of the calendar (I write "10/20/2008", I want to see
"10/20/2008" on the server side), I think its better to avoid timezone
information.

Le vendredi 17 octobre 2008 à 06:27 -0700, Howard Lewis Ship a écrit :
> The fix I implemented was to use a simple number (milliseconds since
> the epoch) as the transfer format.  I'm concerned there may be a time
> zone issue though, when the browser time zone is not the same as the
> server time zone.

-- 
  .~.
  /V\      Mikaël Cluseau <mc...@isi.nc>
 // \\
/(   )\    ISI.NC             +687 26.93.18
 ^`~'^


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


Re: Tapestry 5.0.15 DateField localization problem [patch included]

Posted by Howard Lewis Ship <hl...@gmail.com>.
The fix I implemented was to use a simple number (milliseconds since
the epoch) as the transfer format.  I'm concerned there may be a time
zone issue though, when the browser time zone is not the same as the
server time zone.

On Tue, Oct 14, 2008 at 4:59 PM, Mikaël Cluseau <mc...@gmail.com> wrote:
> Well I still had stability problems under IE (surprise!) so I tried to
> fix the thing in Tapestry itself. AFAIK, it work flowlessly.
>
> Comments welcome ;)
>
> Index: /home/nwrk/workspaces/isi/hatch/tapestry-core-svn/src/main/java/org/apache/tapestry5/corelib/components/DateField.java
> ===================================================================
> --- /home/nwrk/workspaces/isi/hatch/tapestry-core-svn/src/main/java/org/apache/tapestry5/corelib/components/DateField.java      (revision 704286)
> +++ /home/nwrk/workspaces/isi/hatch/tapestry-core-svn/src/main/java/org/apache/tapestry5/corelib/components/DateField.java      (working copy)
> @@ -147,6 +147,9 @@
>         return defaultProvider.defaultValidator("value", resources);
>     }
>
> +    private static final DateFormat EXCHANGE_FORMAT = new
> SimpleDateFormat(
> +            "EEE MMM dd hh:mm:ss 'GMT'Z yyyy", Locale.ENGLISH);
> +
>     /**
>      * Ajax event handler, used when initiating the popup. The client
> sends the input value form the field to the server
>      * to parse it according to the server-side format. The response
> contains a "result" key of the formatted date in a
> @@ -162,7 +165,7 @@
>         {
>             Date date = format.parse(input);
>
> -            response.put(RESULT, date.toString());
> +            response.put(RESULT, EXCHANGE_FORMAT.format(date));
>         }
>         catch (ParseException ex)
>         {
>
>
> --
>  .~.
>  /V\      Mikaël Cluseau <mc...@isi.nc>
>  // \\
> /(   )\    ISI.NC             +687 26.93.18
>  ^`~'^
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

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


Re: Tapestry 5.0.15 DateField localization problem [patch included]

Posted by Mikaël Cluseau <mc...@gmail.com>.
Well I still had stability problems under IE (surprise!) so I tried to
fix the thing in Tapestry itself. AFAIK, it work flowlessly.

Comments welcome ;)

Index: /home/nwrk/workspaces/isi/hatch/tapestry-core-svn/src/main/java/org/apache/tapestry5/corelib/components/DateField.java
===================================================================
--- /home/nwrk/workspaces/isi/hatch/tapestry-core-svn/src/main/java/org/apache/tapestry5/corelib/components/DateField.java	(revision 704286)
+++ /home/nwrk/workspaces/isi/hatch/tapestry-core-svn/src/main/java/org/apache/tapestry5/corelib/components/DateField.java	(working copy)
@@ -147,6 +147,9 @@
         return defaultProvider.defaultValidator("value", resources);
     }
 
+    private static final DateFormat EXCHANGE_FORMAT = new
SimpleDateFormat(
+            "EEE MMM dd hh:mm:ss 'GMT'Z yyyy", Locale.ENGLISH);
+
     /**
      * Ajax event handler, used when initiating the popup. The client
sends the input value form the field to the server
      * to parse it according to the server-side format. The response
contains a "result" key of the formatted date in a
@@ -162,7 +165,7 @@
         {
             Date date = format.parse(input);
 
-            response.put(RESULT, date.toString());
+            response.put(RESULT, EXCHANGE_FORMAT.format(date));
         }
         catch (ParseException ex)
         {


-- 
  .~.
  /V\      Mikaël Cluseau <mc...@isi.nc>
 // \\
/(   )\    ISI.NC             +687 26.93.18
 ^`~'^


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


Re: Tapestry 5.0.15 DateField localization problem

Posted by Mikaël Cluseau <mc...@gmail.com>.
Well... for this to work cleanly, you also need to add an "if" around
the whole datefield-tzfix.js, otherwise you get an error when no
datefields exist on your page:

-----snip----------snip----------snip----------snip-----
if (Tapestry.DateField != null) {

[...previous file contents...]

}
-----snip----------snip----------snip----------snip-----

-- 
  .~.
  /V\      Mikaël Cluseau <mc...@isi.nc>
 // \\
/(   )\    ISI.NC             +687 26.93.18
 ^`~'^


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


Re: Tapestry 5.0.15 DateField localization problem

Posted by Mikaël Cluseau <mc...@gmail.com>.
Hello people,

Thanks for your fix Konstantin !

For those (like me) who are using a layout/border, I've refactored your
code in a mixin that includes the workaround javascript in a mixin
suitable for inclusion in layouts. This is a global fix that works for
datefields in beanforms.

Here's my mixin code:

-----snip----------snip----------snip----------snip-----
public class DateFieldTzFix {
	// XXX ---- workaround for TAP5-225 (affects v5.0.15) ---

	@Inject
	private RenderSupport renderSupport;

	@Inject
	@Path("datefield-tzfix.js")
	private Asset script;

	@AfterRender
	void afterRender(MarkupWriter writer) {
		renderSupport.addScriptLink(script);
	}

}
-----snip----------snip----------snip----------snip-----

To use the mixin, simply put this in your layout component:

-----snip----------snip----------snip----------snip-----
public class Layout {

	[...]

	@SuppressWarnings("unused")
	@Mixin
	private DateFieldTzFix dateFieldTzFix;

	[...]

}
-----snip----------snip----------snip----------snip-----

I also advice people (like me, again...) in uncommon locales to add
their GMT specifications in the resultHandler function. My contribution
is :

        tzfix = tzfix.replace(/NCT/, 'GMT+1100');

-- 
  .~.
  /V\      Mikaël Cluseau <mc...@isi.nc>
 // \\
/(   )\    ISI.NC             +687 26.93.18
 ^`~'^


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


Tap 4.1 How to obtain page contain as string ?

Posted by Andrei Stroescu <an...@ime.ro>.
Hello,
I need to transform content of a component or page into string. I need 
this to send contain of the page to email.
Thank you !


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


Re: Weird T5 error page versus component templates

Posted by su...@gmx.de.
Sorry, my mistake:

<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">

was missing around the component template ;-)

-------- Original-Nachricht --------
> Datum: Thu, 02 Oct 2008 11:57:39 +0200
> Von: superoverdrive@gmx.de
> An: "Tapestry users" <us...@tapestry.apache.org>
> Betreff: Weird T5 error page versus component templates

> When I put the following code into a page template it works, if I put it
> inside of a component template embedded within a page, it comes up with the
> error:
> 
> "The prefix "t" for attribute "t:type" is not bound."
> 
> The code:
> 
> <div t:type="t5components/SlidingPanel"
>     subject="literal:panel subject"
>     style="width: 350px;" closed="false">
> <div>
> blablablabla
> </div>
> </div>
> 
> Any ideas?
> 
> Thanks!
> 
> Toby
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org

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


Weird T5 error page versus component templates

Posted by su...@gmx.de.
When I put the following code into a page template it works, if I put it inside of a component template embedded within a page, it comes up with the error:

"The prefix "t" for attribute "t:type" is not bound."

The code:

<div t:type="t5components/SlidingPanel"
    subject="literal:panel subject"
    style="width: 350px;" closed="false">
<div>
blablablabla
</div>
</div>

Any ideas?

Thanks!

Toby

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


Re: Tapestry 5.0.15 DateField localization problem

Posted by Doublel <mo...@gmail.com>.
That is right ,Thanks a lot.

2008/10/2 Jecki <je...@gmail.com>

> On Thu, Oct 2, 2008 at 7:20 AM, Doublel <mo...@gmail.com> wrote:
> > Thank  you for your fix, It can work by default. but When i user
> > t:format="yyyy/mm/dd" for dateFIeld to format the data ,it  return
> > '2008/00/26' too .the month is always "00".
> >
> >
>
> I believe the format should be "yyyy/MM/dd" as "mm" (lower case m) is
> for indicating "minute in hour"
> (http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html),
> CMIIW.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
得与失都是生活

Re: Tapestry 5.0.15 DateField localization problem

Posted by Jecki <je...@gmail.com>.
On Thu, Oct 2, 2008 at 7:20 AM, Doublel <mo...@gmail.com> wrote:
> Thank  you for your fix, It can work by default. but When i user
> t:format="yyyy/mm/dd" for dateFIeld to format the data ,it  return
> '2008/00/26' too .the month is always "00".
>
>

I believe the format should be "yyyy/MM/dd" as "mm" (lower case m) is
for indicating "minute in hour"
(http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html),
CMIIW.

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


Re: Tapestry 5.0.15 DateField localization problem

Posted by Doublel <mo...@gmail.com>.
Thank  you for your fix, It can work by default. but When i user
t:format="yyyy/mm/dd" for dateFIeld to format the data ,it  return
'2008/00/26' too .the month is always "00".



2008/10/1 Konstantin <ch...@ukr.net>

>
> Ok. I've created a workaround.
>
> package myapphere.mixins;
>
> import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
> import org.apache.tapestry5.annotations.MixinAfter;
>
> @IncludeJavaScriptLibrary("datefield-tzfix.js")
> @MixinAfter
> public class DateFieldTzFix {
> }
>
> -----
> Using in:
> -page class:
>
>    private Date dateValue;
>
>    @Component(parameters = {"value=dateValue"})
>    @Mixins("DateFieldTzFix")
>    private DateField dateField;
>
> -tml:
>
>    <t:datefield t:id="dateField"/>
>
> And I added just my timezones: EEST, EET. So you'll have to add your own
> too
> in datefield-tzfix.js script see attachement.
> http://www.nabble.com/file/p19756273/datefield-tzfix.js datefield-tzfix.js
> --
> View this message in context:
> http://www.nabble.com/Tapestry-5.0.15-DateField-localization-problem-tp19723586p19756273.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
得与失都是生活

Re: Tapestry 5.0.15 DateField localization problem

Posted by Konstantin <ch...@ukr.net>.
Ok. I've created a workaround.

package myapphere.mixins;

import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary;
import org.apache.tapestry5.annotations.MixinAfter;

@IncludeJavaScriptLibrary("datefield-tzfix.js")
@MixinAfter
public class DateFieldTzFix {
}

-----
Using in:
-page class:

    private Date dateValue;

    @Component(parameters = {"value=dateValue"})
    @Mixins("DateFieldTzFix")
    private DateField dateField;

-tml:

    <t:datefield t:id="dateField"/>

And I added just my timezones: EEST, EET. So you'll have to add your own too
in datefield-tzfix.js script see attachement.
http://www.nabble.com/file/p19756273/datefield-tzfix.js datefield-tzfix.js 
-- 
View this message in context: http://www.nabble.com/Tapestry-5.0.15-DateField-localization-problem-tp19723586p19756273.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Tapestry 5.0.15 DateField localization problem

Posted by Doublel <mo...@gmail.com>.
I encounter the same problem.
I use:
<span t:type= "Label" t:for="userDateField"></span><input t:type
="DateField" t:format="yyyy/mm/dd" t:value="userDateField"
t:id="userDateField"/>

In FF explorer  I choose today   It return  "2008/00/13".
In IE explorer  I run into javascrip error  'style' is null or not an
object. and when I second choose date  It return  "2008/00/13". too







-- 
得与失都是生活