Discussion:
Is there any way to display a Date as text in the format I wondering?
Ryan Pan
2005-12-15 10:25:53 UTC
Permalink
Hi all,
I met a problem with displaying the a Date variable as text. I even can
not choose the display format of Date.
For example: a Date variable "Date today = new Date()" which will be
displayed as "Thu Dec 15 00:00:00 CST 2005" on front-page,while
what I wanna is "2005-12-15".
So I am looking forward a way to solve this problem.

Thank,
Ryan.
Prince John, Bedag
2005-12-15 12:30:14 UTC
Permalink
Hi Ryan,

Generally, in Java you can use (Simple)DateFormat to format dates.

In Tapestry, attach a DateTranslator to the field - you can define the
pattern as a parameter in your hivemodule.xml - or use the DatePicker,
passing a format parameter.

This sort of stuff is covered in Tapestry in Action, or in the user's
guide.

Best wishes

John

-----Original Message-----
From: Ryan Pan [mailto:***@gmail.com]
Sent: Thursday, December 15, 2005 11:26 AM
To: tapestry-***@jakarta.apache.org
Subject: Is there any way to display a Date as text in the format I
wondering?

Hi all,
I met a problem with displaying the a Date variable as text. I even
can
not choose the display format of Date.
For example: a Date variable "Date today = new Date()" which will be
displayed as "Thu Dec 15 00:00:00 CST 2005" on front-page,while
what I wanna is "2005-12-15".
So I am looking forward a way to solve this problem.

Thank,
Ryan.

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-***@jakarta.apache.org
For additional commands, e-mail: tapestry-user-***@jakarta.apache.org
Paul Cantrell
2005-12-15 16:27:06 UTC
Permalink
Right. Here's an example:

<span jwcid="@Insert" value="ognl:modificationTime"
format="ognl:dateFormat"/>

public DateFormat getDateFormat() { return dateFormat; }
private static final DateFormat dateFormat = new SimpleDateFormat
("yyyy-MMM-dd HH:mm");

I believe you can also inline the format in the page, though it's a
bit messier:

<span jwcid="@Insert" value="ognl:modificationTime" format="ognl:new
java.text.SimpleDateFormat('yyyy-MMM-dd HH:mm')"/>

(Warning: that second bit there is untested code.)

Cheers,

Paul

_________________________________________________________________
Piano music podcast: http://inthehands.com
Other interesting stuff: http://innig.net
Post by Prince John, Bedag
Hi Ryan,
Generally, in Java you can use (Simple)DateFormat to format dates.
In Tapestry, attach a DateTranslator to the field - you can define the
pattern as a parameter in your hivemodule.xml - or use the DatePicker,
passing a format parameter.
This sort of stuff is covered in Tapestry in Action, or in the user's
guide.
Best wishes
John
-----Original Message-----
Sent: Thursday, December 15, 2005 11:26 AM
Subject: Is there any way to display a Date as text in the format I
wondering?
Hi all,
I met a problem with displaying the a Date variable as text. I even
can
not choose the display format of Date.
For example: a Date variable "Date today = new Date()" which will be
displayed as "Thu Dec 15 00:00:00 CST 2005" on front-page,while
what I wanna is "2005-12-15".
So I am looking forward a way to solve this problem.
Thank,
Ryan.
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-***@jakarta.apache.org
For additional commands, e-mail: tapestry-user-***@jakarta.apache.org
Ryan Pan
2005-12-16 04:06:12 UTC
Permalink
all,
It works.Thank you very much.
Ryan.
Post by Paul Cantrell
format="ognl:dateFormat"/>
public DateFormat getDateFormat() { return dateFormat; }
private static final DateFormat dateFormat = new SimpleDateFormat
("yyyy-MMM-dd HH:mm");
I believe you can also inline the format in the page, though it's a
java.text.SimpleDateFormat('yyyy-MMM-dd HH:mm')"/>
(Warning: that second bit there is untested code.)
Cheers,
Paul
_________________________________________________________________
Piano music podcast: http://inthehands.com
Other interesting stuff: http://innig.net
Post by Prince John, Bedag
Hi Ryan,
Generally, in Java you can use (Simple)DateFormat to format dates.
In Tapestry, attach a DateTranslator to the field - you can define the
pattern as a parameter in your hivemodule.xml - or use the DatePicker,
passing a format parameter.
This sort of stuff is covered in Tapestry in Action, or in the user's
guide.
Best wishes
John
-----Original Message-----
Sent: Thursday, December 15, 2005 11:26 AM
Subject: Is there any way to display a Date as text in the format I
wondering?
Hi all,
I met a problem with displaying the a Date variable as text. I even
can
not choose the display format of Date.
For example: a Date variable "Date today = new Date()" which will be
displayed as "Thu Dec 15 00:00:00 CST 2005" on front-page,while
what I wanna is "2005-12-15".
So I am looking forward a way to solve this problem.
Thank,
Ryan.
---------------------------------------------------------------------
---------------------------------------------------------------------
Chihpeng Lin
2005-12-16 07:26:44 UTC
Permalink
I am a newbie of Tapestry.

I looked up the API of StringValidator.

It says:

Simple validation of strings, to enforce required, and minimum length (maximum length is enforced in the client browser, by setting a maximum input length on the text field).

What if the string is a non single byte string?
For example a Chinese UTF8 string which takes 3 bytes.
We can use maxlength in input object to limit string length.
It causes problems when it is inserted into database.

Do we have a validator which can check the max length in bytes of a string?

Thanks.


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Kent Tong
2005-12-17 13:46:00 UTC
Permalink
Post by Chihpeng Lin
Do we have a validator which can check the max length in bytes of a string?
Not that I know of. But you can create your own. BTW, for Tapestry 4
you should use the validators like MaxLength, MinLength and others
in the org.apache.tapestry.form.validator package, not those in
the org.apache.tapestry.valid package.

--
Author of a book for learning Tapestry (http://www.agileskills2.org/EWDT)


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-***@jakarta.apache.org
For additional commands, e-mail: tapestry-user-***@jakarta.apache.org
Chihpeng Lin
2005-12-19 02:06:44 UTC
Permalink
Thank you very much.

I've created a validator to check the byte length of a string.
It's not too difficult to create a validator in server side.
I haven't figured out how to create a client side validator.
Don't know how to integrate javascript into the validator yet.

But I have a problem when displaying the error message of my own validator.
I prepared both English and Chinese message property files (en_US and zh_TW).

The language of My OS is traditional Chinese.
In Firefox, it displays Chinese message (zh_TW) in Tapestry's validator, but it displays English message (en_US) in my own validator.

The most wierd thing is that my validator works correctly in IE6. It displays Chinese
message just like what Tapestry's validators do.

Regards,
Chihpeng Lin
Post by Chihpeng Lin
Do we have a validator which can check the max length in bytes of a string?
Not that I know of. But you can create your own. BTW, for Tapestry 4
you should use the validators like MaxLength, MinLength and others
in the org.apache.tapestry.form.validator package, not those in
the org.apache.tapestry.valid package.

--
Author of a book for learning Tapestry (http://www.agileskills2.org/EWDT)


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-***@jakarta.apache.org
For additional commands, e-mail: tapestry-user-***@jakarta.apache.org




__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Kent Tong
2005-12-19 17:07:22 UTC
Permalink
Post by Chihpeng Lin
In Firefox, it displays Chinese message (zh_TW) in Tapestry's validator, but
it displays English message (en_US) in my own validator.
The most wierd thing is that my validator works correctly in IE6. It
displays Chinese message just like what Tapestry's validators do.
Check the preferred languages setting in FireFox. Make sure it is
listing zh-tw at the top instead of zh.

--
Author of a book for learning Tapestry (http://www.agileskills2.org/EWDT)


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-***@jakarta.apache.org
For additional commands, e-mail: tapestry-user-***@jakarta.apache.org
Paul Cantrell
2005-12-17 15:54:50 UTC
Permalink
Note that a string has no single well-defined length in bytes -- it
depends on the encoding. This hypothetical validator would thus need
to take an encoding as a parameter, and you'll have to make sure it
matches your DB's encoding. Be careful! It's a sticky problem.

That said, it would be a useful thing to have in contrib if properly
written.

Cheers,

Paul
Post by Chihpeng Lin
I am a newbie of Tapestry.
I looked up the API of StringValidator.
Simple validation of strings, to enforce required, and minimum
length (maximum length is enforced in the client browser, by
setting a maximum input length on the text field).
What if the string is a non single byte string?
For example a Chinese UTF8 string which takes 3 bytes.
We can use maxlength in input object to limit string length.
It causes problems when it is inserted into database.
Do we have a validator which can check the max length in bytes of a string?
Thanks.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_________________________________________________________________
Piano music podcast: http://inthehands.com
Other interesting stuff: http://innig.net



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-***@jakarta.apache.org
For additional commands, e-mail: tapestry-user-***@jakarta.apache.org
Ryan Pan
2005-12-17 16:27:52 UTC
Permalink
All,
Another question,If I wanna show all the date fields of whole page in
one format,is there any way to set Date format for one time but impact whole
page?

Thanks,
Ryan.
Post by Ryan Pan
all,
It works.Thank you very much.
Ryan.
Post by Paul Cantrell
format="ognl:dateFormat"/>
public DateFormat getDateFormat() { return dateFormat; }
private static final DateFormat dateFormat = new SimpleDateFormat
("yyyy-MMM-dd HH:mm");
I believe you can also inline the format in the page, though it's a
java.text.SimpleDateFormat('yyyy-MMM-dd HH:mm')"/>
(Warning: that second bit there is untested code.)
Cheers,
Paul
_________________________________________________________________
Piano music podcast: http://inthehands.com
Other interesting stuff: http://innig.net
Post by Prince John, Bedag
Hi Ryan,
Generally, in Java you can use (Simple)DateFormat to format dates.
In Tapestry, attach a DateTranslator to the field - you can define the
pattern as a parameter in your hivemodule.xml - or use the DatePicker,
passing a format parameter.
This sort of stuff is covered in Tapestry in Action, or in the user's
guide.
Best wishes
John
-----Original Message-----
Sent: Thursday, December 15, 2005 11:26 AM
Subject: Is there any way to display a Date as text in the format I
wondering?
Hi all,
I met a problem with displaying the a Date variable as text. I even
can
not choose the display format of Date.
For example: a Date variable "Date today = new Date()" which will be
displayed as "Thu Dec 15 00:00:00 CST 2005" on front-page,while
what I wanna is "2005-12-15".
So I am looking forward a way to solve this problem.
Thank,
Ryan.
---------------------------------------------------------------------
---------------------------------------------------------------------
Fernando Padilla
2005-12-17 17:20:04 UTC
Permalink
One way would be to just use what Paul already pointed out. You define
one dateFormat property, and you use that same dateFormat property
across all date Inserts.

But maybe you meant change the format without having to explicitly set
it. In that case, you'll probably have to create your own DateInsert
component that behaves as you want it to behave (default format).
Post by Ryan Pan
All,
Another question,If I wanna show all the date fields of whole page in
one format,is there any way to set Date format for one time but impact whole
page?
Thanks,
Ryan.
Post by Ryan Pan
all,
It works.Thank you very much.
Ryan.
Post by Paul Cantrell
format="ognl:dateFormat"/>
public DateFormat getDateFormat() { return dateFormat; }
private static final DateFormat dateFormat = new SimpleDateFormat
("yyyy-MMM-dd HH:mm");
I believe you can also inline the format in the page, though it's a
java.text.SimpleDateFormat('yyyy-MMM-dd HH:mm')"/>
(Warning: that second bit there is untested code.)
Cheers,
Paul
_________________________________________________________________
Piano music podcast: http://inthehands.com
Other interesting stuff: http://innig.net
Post by Prince John, Bedag
Hi Ryan,
Generally, in Java you can use (Simple)DateFormat to format dates.
In Tapestry, attach a DateTranslator to the field - you can define the
pattern as a parameter in your hivemodule.xml - or use the DatePicker,
passing a format parameter.
This sort of stuff is covered in Tapestry in Action, or in the user's
guide.
Best wishes
John
-----Original Message-----
Sent: Thursday, December 15, 2005 11:26 AM
Subject: Is there any way to display a Date as text in the format I
wondering?
Hi all,
I met a problem with displaying the a Date variable as text. I even
can
not choose the display format of Date.
For example: a Date variable "Date today = new Date()" which will be
displayed as "Thu Dec 15 00:00:00 CST 2005" on front-page,while
what I wanna is "2005-12-15".
So I am looking forward a way to solve this problem.
Thank,
Ryan.
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-***@jakarta.apache.org
For additional commands, e-mail: tapestry-user-***@jakarta.apache.org
Loading...