click-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bob Schellink <sab...@gmail.com>
Subject HiddenField doesn't work with Timestamp, Time or java.sql.Date
Date Mon, 19 Jan 2009 21:31:34 GMT
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)) {
     // catchall check
   }


bob

Mime
View raw message