chingshuang tso created TOMAHAWK-1683:
-----------------------------------------
Summary: <t:inputDate> doesn't accept a leading empty space for a
date
Key: TOMAHAWK-1683
URL: https://issues.apache.org/jira/browse/TOMAHAWK-1683
Project: MyFaces Tomahawk
Issue Type: Bug
Components: JSF2
Affects Versions: 1.1.14
Environment: software platform
Reporter: chingshuang tso
Priority: Minor
On JSF page, we use <t:inputDate> to display Date/Time field on UI. And when
user type "leading empty space" for date field(for example, user try to type
"1" for Date on UI, but accidentally he type " 1 ", and then click on submit.
Because of space, it will throw error.
I trace the src code and find out the problem is on
org.apache.myfaces.custom.date.AbstractHtmlInputDate, when it parse, it throw
the error in the following:
public Date parse() throws ParseException{
.....
try {
...
tempCalendar.set(Calendar.DAY_OF_MONTH,Integer.parseInt(day));
...
} catch (NumberFormatException e) {
throw new ParseException(e.getMessage(),0);
} catch (IllegalArgumentException e) {
throw new ParseException(e.getMessage(),0);
}
}
As you can see, day is " 1 " in my use case, and it will throw the error. So
the best solution is we need to do in the following way:
tempCalendar.set(Calendar.DAY_OF_MONTH,Integer.parseInt(day.trim()));
Same issue happen on hours/minutes/second
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)