You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Christopher Cheng <ch...@netdimensions.com> on 2002/01/02 09:39:59 UTC

Why is PropertyEditor conversion not added in PropertyUtils.setSimpleProperty?

How come PropertyUtils.setSimpleProperty (…) doesn’t have a PropertyEditor
built in?

It would be nice to have something like this.


public static void setSimpleProperty(Object bean, String name, Object value)
throws IllegalAccessException, InvocationTargetException,
NoSuchMethodException {

    …..,,, codes …..

    PropertyEditor editor =
PropertyEditorManager.findEditor(descriptor.getPropertyType());
    try {
        if (editor != null) {
            editor.setValue(values[0]);
            values[0] = editor.getValue();
        }
    }
    catch (Exception e) {
        e.printStackTrace(System.out);
    }

writeMethod.invoke(bean, values);
}