/** * Set the value of a single field specified by field name in the bean from the ui. * * @param uiObject * @param bean * @param fieldName * @throws Exception */ public static void uiToBean(final Object uiObject, final Object bean, final String fieldName) throws Exception { if (fieldName == null) throw new Exception("Null fieldName passed to uiToBean. Please set the field name."); final IFieldWidget box = BeanUIWithoutOSGi.getFieldWidget(fieldName, uiObject); if (box == null) return; // Not all properties have to be in the UI. if (!box.isActivated()) return; final Object ob = box.getValue(); if (ob != null && !isNaN(ob) && !isInfinity(ob)) { RichBeanUtils.setBeanValue(bean, fieldName, ob); } else { // Required to fix fields inside a list editor being edited to no value. if (ob != null) { final Method setter = bean.getClass().getMethod(RichBeanUtils.getSetterName(fieldName), ob.getClass()); setter.invoke(bean, ob.getClass().cast(null)); } } }