Raized ClassCastException when Comparing 2 InputDate with validateCompareTo
---------------------------------------------------------------------------

                 Key: TOMAHAWK-750
                 URL: http://issues.apache.org/jira/browse/TOMAHAWK-750
             Project: MyFaces Tomahawk
          Issue Type: Bug
          Components: Validators
    Affects Versions: 1.1.5-SNAPSHOT
         Environment: windows XP
            Reporter: Nuno Marques


I have two inputDate components with their own validators and a compareTo 
validator:

<t:inputDate id="startDateInput" value="#{viewController.start}"
  type="both" popupCalendar="true">
  <f:validator validatorId="validateDate" />
</t:inputDate>

<t:inputDate id="endDateInput" value="#{viewController.end}"
  type="both" popupCalendar="true">
  <f:validator validatorId="validateDate" />
  <s:validateCompareTo operator="gt" for="startDateInput" 
message="#{appBundle.invalidDate}" />
</t:inputDate>

When, for instance, the validator of the "startDateInput" throws a 
ValidatorException and sets the valid property as false, validateCompareTo 
raizes a ClastCastException saying that class UserData is not Comparable.

I looking deeper into the source code and found that:

1 - The class UserData is an internal representation of the submitted value by 
the InputDate component (though the class is public).

2 - The validateCompareTo gets this internal representation when he gets the 
submitted value because the value is not valid.

3 - When one or both values of the compared components are not Comparable, a 
ClassCastException is raized.

I am submitting this as a bug because:

1 - I think that internal representations of objects shouldn't be accessed 
outside the scope of the objects.

2 - The JSF spec 1.1 says that (pag.3-18; 3.2.5.1) :

submittedValue

RW Object 

The submitted, unconverted, value of this component. This property should only 
be set by the decode() method of this component, or its corresponding Renderer, 
or by the validate method of this component. This property should only be read 
by the validate() method of this component.

3 - When I saw the Javadoc of validateCompareTo, I found the following 
statement:

If no comparator is specified, the component values must implement Comparable 
and are compared using compareTo(). If either value or foreign value does not 
implement Comparable and no Comparator is specified, validation always succeeds.

-- 
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