dev@javaserverfaces.java.net

Type Coercion not working with composite components?

From: Jason Lee <jason_at_steeplesoft.com>
Date: Tue, 19 Jan 2010 17:29:17 -0600

Let's say I have this attribute on a composite component:

<composite:attribute name="foo" type="java.lang.Integer" default="50"/>

Let's also say I have a Java class backing the composite component (to
generate config strings, etc). In this Java class, I have a line of
code like this:

     Integer foo = (Integer)getAttributes().get("foo");

While I should get an Integer with the value of 50, get() returns a
String with the value "50" resulting in a CCE.

My question, then, is this: is my expectation in the code above
reasonable? That is, should we be seeing type coercion here and I've
just hit a bug? If the answer is yes, I can file an issue and try to
track down a fix for it. If not, I guess I'll have to do a bit more
work in the Java code that deals with the attribute map.

-- 
Jason Lee, SCJP
President, Oklahoma City Java Users Group
Senior Java Developer, Sun Microsystems
http://blogs.steeplesoft.com