Uploaded image for project: 'Click'
  1. Click
  2. CLK-484

HiddenField doesn't work with java.sql.Timestamp, java.sql.Time and java.sql.Date

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.5
    • 2.0.1, 1.5.1
    • core
    • None

    Description

      When setting a HiddenField's valueClass to Timestamp, an exception is thrown in HiddenField#bindRequestValue:

      java.lang.IllegalArgumentException: The value.getClass(): 'java.util.Date' must be the same as the HiddenField valueClass: 'java.sql.Timestamp'
      at org.apache.click.control.HiddenField.setValueObject(HiddenField.java:239)
      at org.apache.click.control.HiddenField.bindRequestValue(HiddenField.java:295)
      at org.apache.click.control.HiddenFieldTest.testTimestampCopy(HiddenFieldTest.java:66)

      An easy fix is to add extra checks for #bindRequestValue:

      else if (valueClass == Timestamp.class)

      { long time = Long.parseLong(aValue); setValueObject(new Timestamp(time)); }

      else if (valueClass == java.sql.Date.class)

      { long time = Long.parseLong(aValue); setValueObject(new java.sql.Date(time)); }

      else if (valueClass == Time.class)

      { long time = Long.parseLong(aValue); setValueObject(new Time(time)); }

      else if (Date.class.isAssignableFrom(valueClass)) {
      }

      Attachments

        Activity

          People

            sabob Bob Schellink
            sabob Bob Schellink
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: