You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Miroslav Nachev <mi...@space-comm.com> on 2009/04/28 15:48:58 UTC

How to set some property using BeanUtils when the propery value (enum) is passed as String

Hi,

When I try to set one Enum property using BeanUtilsBean I have the 
following exception:
java.lang.IllegalArgumentException: Cannot invoke 
org.jdesktop.swingx.JXIntegerField.setNumberType on bean class 'class 
com.cosmos.swingb.JBIntegerField' - argument type mismatch - had objects 
of type "java.lang.String" but expected signature 
"org.jdesktop.swingx.JXIntegerField$NumberType"
        at 
org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:2181)
        at 
org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:2141)
        at 
org.apache.commons.beanutils.PropertyUtilsBean.setNestedProperty(PropertyUtilsBean.java:1948)
        at 
org.apache.commons.beanutils.PropertyUtilsBean.setProperty(PropertyUtilsBean.java:2054)
        at 
org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1015)
        at 
com.cosmos.acacia.gui.entity.AbstractEntityPanel.main(AbstractEntityPanel.java:614)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at 
org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:2155)
        ... 5 more

This is not happen when property type is integer:
            BeanUtilsBean beanUtils = BeanUtilsBean.getInstance();
            beanUtils.setProperty(integerField, "columns", "7");
            beanUtils.setProperty(integerField, "numberType", "LongType");

Any suggestions how can solve the problem?


Regards,
Miro.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org