org.jdesktop.binding
Class JavaBeanDataModel

java.lang.Object
  extended by org.jdesktop.binding.AbstractDataModel
      extended by org.jdesktop.binding.DefaultDataModel
          extended by org.jdesktop.binding.JavaBeanDataModel
All Implemented Interfaces:
DataModel, MetaDataProvider

public class JavaBeanDataModel
extends DefaultDataModel

A class that creates a collection of MetaData based BeanInfo PropertyDescriptors. To use this class:

  1. Construct the model using the Bean class you wish to model
  2. use setJavaBean to set the current object of this class.
  3. Updates made to the form will update the property values of the bean.

TODO: Using JavaBeans as a data source should be generalized and not constrained to FormModels.

Author:
Mark Davidson

Field Summary
 java.beans.PropertyChangeListener propertyChangeListener
           
 
Fields inherited from class org.jdesktop.binding.AbstractDataModel
validators
 
Constructor Summary
JavaBeanDataModel(java.lang.Class beanClass)
           
JavaBeanDataModel(java.lang.Class beanClass, java.lang.Object bean)
          Constructs a JavaBeanDataModel by introspecting on the class and using the data from the object as the current bean
JavaBeanDataModel(java.lang.Class beanClass, java.lang.Object bean, MetaData[] metaData)
           
JavaBeanDataModel(java.lang.Object bean)
           
 
Method Summary
 java.lang.Object getJavaBean()
          Get the JavaBean instance that this model uses.
 java.lang.Object getValue(java.lang.String fieldName)
           
 void setJavaBean(java.lang.Object bean)
          Set the JavaBean instance that this model will use.
protected  void setValueImpl(java.lang.String fieldName, java.lang.Object value)
           
 
Methods inherited from class org.jdesktop.binding.DefaultDataModel
addField, addField, getFieldCount, getFieldNames, getMetaData, getRecordCount, getRecordIndex, removeField, setRecordIndex
 
Methods inherited from class org.jdesktop.binding.AbstractDataModel
addValidator, addValueChangeListener, fireValueChanged, getMetaData, getValidators, getValueChangeListeners, removeValidator, removeValueChangeListener, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

propertyChangeListener

public java.beans.PropertyChangeListener propertyChangeListener
Constructor Detail

JavaBeanDataModel

public JavaBeanDataModel(java.lang.Class beanClass)
                  throws java.beans.IntrospectionException
Throws:
java.beans.IntrospectionException

JavaBeanDataModel

public JavaBeanDataModel(java.lang.Object bean)
                  throws java.beans.IntrospectionException
Throws:
java.beans.IntrospectionException

JavaBeanDataModel

public JavaBeanDataModel(java.lang.Class beanClass,
                         java.lang.Object bean)
                  throws java.beans.IntrospectionException
Constructs a JavaBeanDataModel by introspecting on the class and using the data from the object as the current bean

Parameters:
beanClass - the class to use to introspect properties
bean - the object where the current values will be retrieved and stored.
Throws:
java.beans.IntrospectionException

JavaBeanDataModel

public JavaBeanDataModel(java.lang.Class beanClass,
                         java.lang.Object bean,
                         MetaData[] metaData)
                  throws java.beans.IntrospectionException
Throws:
java.beans.IntrospectionException
Method Detail

setJavaBean

public void setJavaBean(java.lang.Object bean)
Set the JavaBean instance that this model will use.


getJavaBean

public java.lang.Object getJavaBean()
Get the JavaBean instance that this model uses.


getValue

public java.lang.Object getValue(java.lang.String fieldName)
Specified by:
getValue in interface DataModel
Overrides:
getValue in class DefaultDataModel
Parameters:
fieldName - String containing the name of the field
Returns:
Object containing the current value of the named field

setValueImpl

protected void setValueImpl(java.lang.String fieldName,
                            java.lang.Object value)
Overrides:
setValueImpl in class DefaultDataModel


Copyright © 2005 Sun Microsystems All Rights Reserved.