/** * <p>Return the Java Class representing the property type of the specified * property, or <code>null</code> if there is no such property for the * specified bean.</p> * * <p>For more details see <code>PropertyUtilsBean</code>.</p> * * @param bean Bean for which a property descriptor is requested * @param name Possibly indexed and/or nested name of the property for * which a property descriptor is requested * @return The property type * * @throws IllegalAccessException if the caller does not have * access to the property accessor method * @throws IllegalArgumentException if <code>bean</code> or * <code>name</code> is null * @throws IllegalArgumentException if a nested reference to a * property returns null * @throws InvocationTargetException if the property accessor method * throws an exception * @throws NoSuchMethodException if an accessor method for this * propety cannot be found * @see PropertyUtilsBean#getPropertyType(Object, String) */ public static Class<?> getPropertyType(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return PropertyUtilsBean.getInstance().getPropertyType(bean, name); }
/** * <p>Return the Java Class representing the property type of the specified * property, or <code>null</code> if there is no such property for the * specified bean.</p> * * <p>For more details see <code>PropertyUtilsBean</code>.</p> * * @param bean Bean for which a property descriptor is requested * @param name Possibly indexed and/or nested name of the property for * which a property descriptor is requested * @return The property type * * @throws IllegalAccessException if the caller does not have * access to the property accessor method * @throws IllegalArgumentException if <code>bean</code> or * <code>name</code> is null * @throws IllegalArgumentException if a nested reference to a * property returns null * @throws InvocationTargetException if the property accessor method * throws an exception * @throws NoSuchMethodException if an accessor method for this * propety cannot be found * @see PropertyUtilsBean#getPropertyType(Object, String) */ public static Class<?> getPropertyType(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return PropertyUtilsBean.getInstance().getPropertyType(bean, name); }
/** * <p>Return the Java Class representing the property type of the specified * property, or <code>null</code> if there is no such property for the * specified bean.</p> * * <p>For more details see <code>PropertyUtilsBean</code>.</p> * * @param bean Bean for which a property descriptor is requested * @param name Possibly indexed and/or nested name of the property for * which a property descriptor is requested * @return The property type * * @exception IllegalAccessException if the caller does not have * access to the property accessor method * @exception IllegalArgumentException if <code>bean</code> or * <code>name</code> is null * @exception IllegalArgumentException if a nested reference to a * property returns null * @exception InvocationTargetException if the property accessor method * throws an exception * @exception NoSuchMethodException if an accessor method for this * propety cannot be found * @see PropertyUtilsBean#getPropertyType(Object, String) */ public static Class getPropertyType(Object bean, String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return PropertyUtilsBean.getInstance().getPropertyType(bean, name); }
/** * <p>Return the Java Class representing the property type of the specified * property, or <code>null</code> if there is no such property for the * specified bean.</p> * * <p>For more details see <code>PropertyUtilsBean</code>.</p> * * @param bean Bean for which a property descriptor is requested * @param name Possibly indexed and/or nested name of the property for * which a property descriptor is requested * @return The property type * * @throws IllegalAccessException if the caller does not have * access to the property accessor method * @throws IllegalArgumentException if <code>bean</code> or * <code>name</code> is null * @throws IllegalArgumentException if a nested reference to a * property returns null * @throws InvocationTargetException if the property accessor method * throws an exception * @throws NoSuchMethodException if an accessor method for this * propety cannot be found * @see PropertyUtilsBean#getPropertyType(Object, String) */ public static Class<?> getPropertyType(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return PropertyUtilsBean.getInstance().getPropertyType(bean, name); }
/** * <p>Return the Java Class representing the property type of the specified * property, or <code>null</code> if there is no such property for the * specified bean.</p> * * <p>For more details see <code>PropertyUtilsBean</code>.</p> * * @param bean Bean for which a property descriptor is requested * @param name Possibly indexed and/or nested name of the property for * which a property descriptor is requested * @return The property type * * @exception IllegalAccessException if the caller does not have * access to the property accessor method * @exception IllegalArgumentException if <code>bean</code> or * <code>name</code> is null * @exception IllegalArgumentException if a nested reference to a * property returns null * @exception InvocationTargetException if the property accessor method * throws an exception * @exception NoSuchMethodException if an accessor method for this * propety cannot be found * @see PropertyUtilsBean#getPropertyType(Object, String) */ public static Class getPropertyType(Object bean, String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return PropertyUtilsBean.getInstance().getPropertyType(bean, name); }
/** * <p>Return the Java Class representing the property type of the specified * property, or <code>null</code> if there is no such property for the * specified bean.</p> * * <p>For more details see <code>PropertyUtilsBean</code>.</p> * * @param bean Bean for which a property descriptor is requested * @param name Possibly indexed and/or nested name of the property for * which a property descriptor is requested * @return The property type * * @exception IllegalAccessException if the caller does not have * access to the property accessor method * @exception IllegalArgumentException if <code>bean</code> or * <code>name</code> is null * @exception IllegalArgumentException if a nested reference to a * property returns null * @exception InvocationTargetException if the property accessor method * throws an exception * @exception NoSuchMethodException if an accessor method for this * propety cannot be found * @see PropertyUtilsBean#getPropertyType(Object, String) */ public static Class getPropertyType(Object bean, String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { return PropertyUtilsBean.getInstance().getPropertyType(bean, name); }
public static void setComplexProperty(Object bean, String name, Object value) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException, InstantiationException { if (!name.contains(".")) { BeanUtil.setProperty(bean, name, value); return; } PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean(); String[] propertyLevels = name.split("\\."); String parentPropertyName = ""; for (int i = 0; i < propertyLevels.length; i++) { String p = propertyLevels[i]; parentPropertyName = (parentPropertyName.equals("") ? p : parentPropertyName + "." + p); if (i < (propertyLevels.length - 1) && propertyUtilsBean.getProperty(bean, parentPropertyName) != null) { continue; } Class<?> parentClass = propertyUtilsBean.getPropertyType(bean, parentPropertyName); if (i < (propertyLevels.length - 1)) { BeanUtil.setProperty(bean, parentPropertyName, parentClass.getConstructor().newInstance()); } else { BeanUtil.setProperty(bean, parentPropertyName, parentClass.getConstructor(String.class).newInstance(value)); } } } }
public Binding bind() { if (bound) return this; bound = true; if (model == null) throw new RuntimeException("Missing model!"); if (propertyExpression == null) throw new RuntimeException("No propertyexpression set on binding"); if (ui == null) throw new RuntimeException("No ui component set when when connecting " + propertyExpression); bridge = UIBridgeRegistry.getBridge(ui.getClass()); if (bridge == null) throw new RuntimeException("No UIBridge found for " + ui.getClass() + " when connecting " + propertyExpression); try { this.modelValueType = propertyUtils.getPropertyType(model, propertyExpression); } catch (Exception e) { throw new RuntimeException("Cannot get model type"); } this.uiValueType = bridge.getUIValueType(); flushModelToUI(); configureBindingStrategy(); configureValidationStrategy(); configurePropertyChangeSupport(); return this; }
Object value = null; try { Class type = bean.getPropertyType(m_baseObject, m_baseObjectProperty); value = converter.convert(m_value, type); bean.setNestedProperty(m_baseObject, m_baseObjectProperty, value);
Object value = null; try { Class<?> type = bean.getPropertyType(m_baseObject, m_baseObjectProperty); value = converter.convert(m_value, type); bean.setNestedProperty(m_baseObject, m_baseObjectProperty, value);