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

When type="both", inputDate does not accept null value

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1.5-SNAPSHOT
    • 1.1.5
    • Date
    • None
    • JDK 1.5.0.07, Tomcat 5.5.17 or Tomcat 5.0.28

    Description

      When the value of the type attribute of the inputDate is "both", it is not accepting null values even if required is not true. This can be easily reproduced using the Date example of examples webapp of SNAPAHOT-1.1.5.

      1. Take the date example - (/date.jsf)
      2. Enter null value for the third input component ( Where both date and time is to be entered ) and click on update. This will give a validation error saying that the entered date is not valid.

      I have debugged the code and found out that the actual exception is a NumberFormatException from HtmlInputDate.parse(). This happens because the code bypasses the "isSubmitValid()" function where the submitted values are checked for null. The "isTimeSubmitted()" function returns true in the case of type=both. For type==both, only hours and minutes are to be checked (as in the case of short_time) and there is no need of checking the seconds value (which will have value = 0 in the case of type = both). So the fix can be removal of type.equals("both") from the if condition in the second line of the function.

      Class -> org.apache.myfaces.custom.date.HtmlInputDate

      private boolean isTimeSubmitted(boolean usesAmpm, String type)

      { boolean isTimeSubmitted = ! (StringUtils.isEmpty(getHours()) && StringUtils.isEmpty(getMinutes())); if(type.equals("time") || type.equals("full") || type.equals("both")) isTimeSubmitted = isTimeSubmitted || ! StringUtils.isEmpty(getSeconds()); if(usesAmpm) isTimeSubmitted = isTimeSubmitted || isAmpmSubmitted(); return isTimeSubmitted; }

      Attachments

        Activity

          People

            cagatay_civici Cagatay Civici
            kannan Kannan Muthukkaruppan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: