webtier@glassfish.java.net

Re: [webtier] JSF 2 facelets custom tags with integer attributes

From: Ryan Lubke <Ryan.Lubke_at_Sun.COM>
Date: Tue, 21 Jul 2009 10:37:45 -0700

On 7/21/09 6:47 AM, webtier_at_javadesktop.org wrote:
> I am trying to convert a spinner custom tag example from JSF 1/JSP to JSF 2/facelets. Here is my .taglib.facelets file:
>
> <facelet-taglib version="2.0" ...>
> <namespace>http://corejsf.com</namespace>
> <tag>
> <tag-name>spinner</tag-name>
> <component>
> <component-type>com.corejsf.Spinner</component-type>
> </component>
> <attribute><name>minimum</name><type>int</type></attribute>
> <attribute><name>maximum</name><type>int</type></attribute>
> </tag>
> </facelet-taglib>
>
> When I use the tag
>
> <corejsf:spinner value="#{cardExpirationDate.month}"
> id="monthSpinner" minimum="1" maximum="12" />
>
> the line
>
> Integer minimum = (Integer) getAttributes().get("minimum");
>
> throws a class cast exception. What gives? Does facelets not convert types like JSP does? Is the expected behavior documented anywhere? I couldn't find anything relevant in the JSF 2.0 spec.
>
The <attribute> elements were added for documentation purposes only.

That said, Facelets will try to determine the attribute type by checking
the properties of the component implementation.
If the type cannot be determined, then Object is assumed.

> Thanks,
>
> Cay
> [Message sent by forum member 'cayhorstmann' (cayhorstmann)]
>
> http://forums.java.net/jive/thread.jspa?messageID=356759
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: webtier-help_at_glassfish.dev.java.net
>
>