Uploaded image for project: 'MyFaces Tomahawk'
  1. MyFaces Tomahawk
  2. TOMAHAWK-1683

<t:inputDate> doesn't accept a leading empty space for a date

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.1.14
    • None
    • JSF2
    • None
    • software platform

    Description

      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

      Attachments

        Activity

          People

            Unassigned Unassigned
            chingshuangtso chingshuang tso
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: