Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.1.3
-
None
-
None
Description
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)
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