[ http://issues.apache.org/jira/browse/TOMAHAWK-759?page=all ]

Cagatay Civici resolved TOMAHAWK-759.
-------------------------------------

    Fix Version/s: 1.1.5-SNAPSHOT
       Resolution: Fixed

Fixed by not considering seconds to check for empty submits when type is "both".

> When type="both", inputDate does not accept null value
> ------------------------------------------------------
>
>                 Key: TOMAHAWK-759
>                 URL: http://issues.apache.org/jira/browse/TOMAHAWK-759
>             Project: MyFaces Tomahawk
>          Issue Type: Bug
>          Components: Date
>    Affects Versions: 1.1.5-SNAPSHOT
>         Environment: JDK 1.5.0.07, Tomcat 5.5.17 or Tomcat 5.0.28
>            Reporter: Abhilash Kumar
>         Assigned To: Cagatay Civici
>             Fix For: 1.1.5-SNAPSHOT
>
>
> 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;
>         }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to