Details
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; }