MyFaces Tomahawk
  1. MyFaces Tomahawk
  2. TOMAHAWK-605

compareToValidator JSP tag converts "comparator" property to string instead of Comparator

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.5-SNAPSHOT
    • Fix Version/s: 1.1.5
    • Component/s: Validators
    • Labels:
      None

      Description

      Date: Fri, 28 Jul 2006 20:06:49 +0200
      From: "MT3 MTCube" <mt3.mtcube@gmail.com>
      To: dev@myfaces.apache.org
      Subject: ValidateCompareToTag

      We have used the <s:validateCompareTo> with the "comparator" attribute, we
      have inserted a value binding (like comparator=#

      {bean.myComparator}

      ) in the
      attribute but we have received this exception:

      java.lang.ClassCastException: comparator must be type interface
      java.util.Comparator but is type class java.lang.String
      at
      org.apache.myfaces.custom.comparetovalidator.CompareToValidator.createComparator
      (CompareToValidator.java:347)
      at
      org.apache.myfaces.custom.comparetovalidator.CompareToValidator.validate(
      CompareToValidator.java:292)

      even if we get a java.util.Comparator from the bean.
      We have solved the problem with this patch:

      Index:
      C:/current/tomahawk/sandbox/core/src/main/java/org/apache/myfaces/custom/comparetovalidator/ValidateCompareToTag.java
      ===================================================================

      C:/current/tomahawk/sandbox/core/src/main/java/org/apache/myfaces/custom/comparetovalidator/ValidateCompareToTag.java
      (revision 425405)
      +++
      C:/current/tomahawk/sandbox/core/src/main/java/org/apache/myfaces/custom/comparetovalidator/ValidateCompareToTag.java
      (working copy)
      @@ -71,7 +71,7 @@
      if (_comparator != null)

      { ValueBinding vb = facesContext.getApplication ().createValueBinding(_comparator); - validator.setComparator(vb.getValue(facesContext).toString()); + validator.setComparator(vb.getValue(facesContext)); }

      if (_foreignComponentName != null)

      with this correction the "comparator" property receives the object instead
      at first it receives a String (the cause of the later exception).
      Is it correct or we have used the comparator attribute in a wrong way?

      Thanks to all,
      Mt3

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Mike Kienenberger
            Reporter:
            Mike Kienenberger
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development