JAVA: ICEFACES: component <ice:selectInputDate> mapped on a "java.util.Calendar" field
- by blummihaela
Does anybody knows how can component <ice:selectInputDate> be mapped on a java.util.Calendar field, not java.util.Date?
I am using from IceFaces version 1.8.2, the component <ice:selectInputDate>. This component requires to be bound with a java.util.Date proeprty. For example, value="#{bean.myDate}", the myDate field must be of type java.util.Date. But I need my date field to be of type java.util.Calendar.
My trials: I have tried to use standard converter or a custom one:
Standard one: <f:convertDateTime pattern="dd/MM/yyyy" /> it formats correct the value in GUI, but when setting it on the property bean.myDate of type Calendar I get following error message:
[5/3/10 12:09:18:398 EEST] 00000021
lifecycle I WARNING: FacesMessage(s)
have been enqueued, but may not have
been displayed.
sourceId=j_id12:j_id189:myDate[severity=(ERROR 2),
summary=(/WEB-INF/xhtml............file.xhtml @507,51 value="#{bean.myDate}": Can't
set property 'myDate' on class 'bean'
to value '5/11/10 3:00 AM'.),
detail=(/WEB-INF/xhtml........file.xhtml
@507,51 value="#{bean.myDate}": Can't
set property 'myDate' on class
'...bean...' to value '5/11/10 3:00
AM'.)]
Custom one: <f:converter converterId="c2d"/>
getAsObject - returns the java.util.Calendar object out of the submitted String.
getAsString - receives an Object, and returns the String formatted.
NOTE: this method was hacked so instead of expecting java.util.Calendar, to be complementary with getAsObject method. Instead, the hacked method getAsString, expects an java.util.Date, provided as parameter (by ice:selectInputDate) and returns the String formatted.
But still an error message occurs:
[5/3/10 12:55:34:299 EEST] 0000001f
D2DFaceletVie E
com.icesoft.faces.facelets.D2DFaceletViewHandler
renderResponse Problem in
renderResponse:
java.util.GregorianCalendar
incompatible with java.util.Date
java.lang.ClassCastException: java.util.GregorianCalendar
incompatible with java.util.Date
at com.icesoft.faces.component.selectinputdate.SelectInputDate.getTextToRender(SelectInputDate.java:252)
Any hint is very useful!
Thanks,
Mihaela