ClassCastException when setting timeZone attribute in <f:convertDataTime> using EL ----------------------------------------------------------------------------------
Key: MYFACES-1317 URL: http://issues.apache.org/jira/browse/MYFACES-1317 Project: MyFaces Core Type: Bug Versions: 1.1.3 Reporter: Paul Spencer I am setting the time zone attribute for the tag <f:convertDataTime> from a backing bean. This causes the following ClassCastException in core 1.1.3 Caused by: java.lang.ClassCastException at org.apache.myfaces.shared_impl.taglib.core.ConvertDateTimeTagBase.setConverterTimeZone(ConvertDateTimeTagBase.java:165) at org.apache.myfaces.shared_impl.taglib.core.ConvertDateTimeTagBase.createConverter(ConvertDateTimeTagBase.java:85) at javax.faces.webapp.ConverterTag.doStartTag(ConverterTag.java:63) If I hard code the time zone in the attribute, i.e. timeZone="GMT-05:00", no exception is thrown. When I changed my method getTimeZone() to return a TimeZone, things worked as expected. I guess my confusion comes from the TLD Documentation, http://myfaces.apache.org/impl/tlddoc/index.html. "When this value is a value-binding to a TimeZone instance, that timezone is used. Otherwise this value is treated as a String containing a timezone id, ie as the ID parameter of method java.util.TimeZone.getTimeZone(String)." I read this to mean that the converter would converter would treat String value-binding the same way as a String value. Below is a coded version of my expectation. if (UIComponentTag.isValueReference(value)) { ValueBinding vb = facesContext.getApplication().createValueBinding(value); TimeZone timeZone; Object value = vb.getValue(facesContext); if (value instanceof TimeZone) { timeZone = (TimeZone) value; } else { timeZone = TimeZone.getTimeZone(value.toString()) } converter.setTimeZone(timeZone); } >From Matthias Wessendorf: Paul- good catch. You are right. RI TLD Doc says the same. Create a bug for MyFaces Core Jira project and asign the ticket please to me ! (matzew) Thanks, Matthias -- 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