Class BeanBindingStrategy

  • All Implemented Interfaces:
    BindingStrategy

    public class BeanBindingStrategy
    extends Object
    implements BindingStrategy

    An implementation of the BindingStrategy interface that operates on Java beans.

    This implementation uses Commons Beanutils for reading and writing properties of Java bean components. The names of form fields are mapped to corresponding names of bean properties. That way data exchange can be performed in both directions.

    Version:
    $Id: BeanBindingStrategy.java 205 2012-01-29 18:29:57Z oheger $
    Author:
    Oliver Heger
    • Constructor Detail

      • BeanBindingStrategy

        public BeanBindingStrategy()
    • Method Detail

      • readProperty

        public Object readProperty​(Object model,
                                   String propertyName)
        Reads a property from a model object. All exceptions related to reflection are re-thrown as FormRuntimeException.
        Specified by:
        readProperty in interface BindingStrategy
        Parameters:
        model - the model object
        propertyName - the name of the property to read
        Returns:
        the value of this property
        Throws:
        FormRuntimeException - if an exception occurs
      • writeProperty

        public void writeProperty​(Object model,
                                  String propertyName,
                                  Object value)
        Writes a property to a model object. All exceptions related to reflection are re-thrown as FormRuntimeException.
        Specified by:
        writeProperty in interface BindingStrategy
        Parameters:
        model - the model object
        propertyName - the name of the property to read
        value - the new value of this property
        Throws:
        FormRuntimeException - if an exception occurs