0

How to make Datebox more tolerant

asked 2008-06-17 12:37:39 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5037892

By: enixser

I have defined a Datebox with the format string "dd-MMM-yyyy" which produces values like "17-Jun-2008". Is there a way to tell the Datebox to accept "17-jun-2008"
and "17-JUN-2008" as well when entered manually? If not, which method should I override in a derived class?

Best regards,
Ralf.

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2008-06-20 03:22:16 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5043245

By: jebberwocky

Take a look the Javadoc
http://www.zkoss.org/javadoc/3.0.5/zul/org/zkoss/zul/Datebox.html#setFormat(java
.lang.String)
and
developer guide
http://www.zkoss.org/doc/devguide/ch07s01s07.html

link publish delete flag offensive edit

answered 2008-06-25 07:51:43 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5053099

By: enixser

I know these documents, but I cannot find any hint that solves my problem. When I define the format as "dd-MMM-yyyy" the datebox only accepts date strings that match the exact case of the month like in this example: "17-Jun-2008". I did not find any format telling the datebox to be case insensitive to also accept "17-jun-2008" and "17-JUN-2008".

I guess it's not possible with a format string as this is not supported by Java.
So, the question is: At which point can I put my hands on to prepare the date string before it is parsed? Which method has to be overridden?

Best regards,
Ralf.

link publish delete flag offensive edit

answered 2008-07-03 07:18:45 +0800

enixser gravatar image enixser
185 3

I want to ask again as I did not get a satisfying answer yet:

Can anyone of the ZK guys point me to a method where the text string of the input field is parsed to the internal Date value. I guess I have to override this method to achieve the expected behavior.

Best regards,
Ralf.

link publish delete flag offensive edit

answered 2008-07-03 08:18:33 +0800

dennis gravatar image dennis
3669 1 6
http://www.javaworld.com....

Hi,
There is a bug about datebox format in some locale (https://sourceforge.net/tracker/index.php?func=detail&aid=2009503&group_id=152762&atid=785191)
However this is not the issue you have.

In your case, for cusomization, you can override zk.parseDate (refer the source in common.js) , in switch case 'M'.
Modify both 'if (zk.SMON.split(/\W+/)[0] == token) { ' to string uppercase compare, then it should work.

You could also track the bug above , to know which version you can remove this customization.

/Dennis

link publish delete flag offensive edit

answered 2008-07-03 13:40:07 +0800

enixser gravatar image enixser
185 3

Hi Dennis,

thanks a lot! It works now as expected.

Best regards,
Ralf.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2008-06-17 12:37:39 +0800

Seen: 262 times

Last updated: Jul 03 '08

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More