-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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>
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?
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?
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.
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;
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.
Asked: 2012-06-11 19:28:11 +0800
Seen: 402 times
Last updated: Jun 22 '12