0

[zk 5.0.11] Timebox format problem

asked 2012-06-11 19:28:11 +0800

gersonlc gravatar image gersonlc
129 1

updated 2012-06-11 19:28:42 +0800

The component is accepting wrong format hour. I typed 29:00 then tab key. The hour is formatted to 05:00. Is it correct?

time.zul

<?page id="indexPage" title="Test" contentType="text/html;charset=UTF-8"?>
<zk>
	<window border="normal" width="30%" position="center" mode="overlapped">
		<grid>
			<columns>
				<column></column>
				<column></column>
			</columns>
			<rows>
				<row>
					<label value="Hour"></label>
					<timebox id="hour" format="HH:mm"></timebox>
				</row>
			</rows>
		</grid>
	</window>
</zk>

delete flag offensive retag edit

8 Replies

Sort by ยป oldest newest

answered 2012-06-12 18:03:10 +0800

gersonlc gravatar image gersonlc
129 1

Hi,

I realized that is a DateFormat class behavior:

Simple test:

	public static void main(String[] args) throws ParseException {
		DateFormat df = new SimpleDateFormat("HH:mm");
		String hour = "29:05";
		Date d = df.parse(hour);
		System.out.println(df.format(d));
	}

prints: 05:05. Someone had the same problem?

link publish delete flag offensive edit

answered 2012-06-12 22:00:29 +0800

zippy gravatar image zippy
504 1 2

is not a problem
29:00 hours is equals to 05:00
29-24 = 5

Monday 29:00 is Tuesday 05:00

link publish delete flag offensive edit

answered 2012-06-13 02:49:03 +0800

gersonlc gravatar image gersonlc
129 1

updated 2012-06-13 12:09:44 +0800

But I won't this behavior. I need the time between 00:00 and 23:59.

I see that datebox has a lenient (see Datebox.setLenient) attribute, but timebox hasn't, why?

link publish delete flag offensive edit

answered 2012-06-13 22:16:54 +0800

zippy gravatar image zippy
504 1 2

i dont understand :P

if you use non-lenient, you get a java exception.

link publish delete flag offensive edit

answered 2012-06-14 13:07:07 +0800

gersonlc gravatar image gersonlc
129 1

Not really!

You try typing 29:05 on textbox? It turns 05:05 on blur! If I receive an exception (WrongValueException binded on componet) I would be very happy!

I think the timebox should have a lenient attribute just as datebox has.

link publish delete flag offensive edit

answered 2012-06-14 14:11:55 +0800

zippy gravatar image zippy
504 1 2

Ahh ok, you need "visual effect"

If the attribute not exists, you will click here and pray

http://tracker.zkoss.org/secure/IssueNavigator.jspa?mode=hide&requestId=10002

link publish delete flag offensive edit

answered 2012-06-18 13:20:40 +0800

gersonlc gravatar image gersonlc
129 1

updated 2012-06-18 18:03:48 +0800

Not just visual effect, but correct validation. 29:00 isn't valid hour!!!
I opened an issue: http://tracker.zkoss.org/browse/ZK-1199

I think there are two manner to fix this:

1) Apply correct client side regex mask (javascript) on the timebox (imho, best fix) or

2) Add lenient attribute that throws WrongValueException if can't parse time. When I set setLenient(false) to DateFormat parsing string "29:00", ParseException throws;

link publish delete flag offensive edit

answered 2012-06-22 13:14:03 +0800

gersonlc gravatar image gersonlc
129 1

updated 2012-06-22 13:14:59 +0800

Hi,

A paliative solution would be setting constraint 'no future' that invalidate 'next day' time :

<timebox id="hour" format="HH:mm" constraint="no future: Invalid time"></timebox>

then, typing 25:30, the validation appears.

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: 2012-06-11 19:28:11 +0800

Seen: 402 times

Last updated: Jun 22 '12

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