You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by aappddeevv <aa...@verizon.net> on 2010/07/15 03:48:21 UTC

attribute values that are not string values - how is the conversion managed

I have an attribute on my class object that is a Class<?> object. I want to
set that in BXML.

 

I keep getting a coercion error about converting  string to a class<?>
object.

 

How do I tell the BXMLSerializer to convert this to a class? Is there a
converter mechanism that I can plug in my conversions?

 

<MyObject myClassAttribute="org.MyClass" />

 

Where myClassAttribute is a Class<?> object.

 

I understand that I can do this long-hand and make the attribute an element,
but I would like to keep the short-form. Doable?

 

 


Re: attribute values that are not string values - how is the conversion managed

Posted by Greg Brown <gk...@mac.com>.
Yes, this is definitely doable. You just need to provide an overload for your setter that takes a string, converts it to a Class (Class.forName()), and calls the string setter.

On Jul 14, 2010, at 9:48 PM, aappddeevv wrote:

> I have an attribute on my class object that is a Class<?> object. I want to set that in BXML.
>  
> I keep getting a coercion error about converting  string to a class<?> object.
>  
> How do I tell the BXMLSerializer to convert this to a class? Is there a converter mechanism that I can plug in my conversions?
>  
> <MyObject myClassAttribute=”org.MyClass” />
>  
> Where myClassAttribute is a Class<?> object.
>  
> I understand that I can do this long-hand and make the attribute an element, but I would like to keep the short-form. Doable?
>  
>