org.jdesktop.binding
Class JavaBeanDataModel
java.lang.Object
org.jdesktop.binding.AbstractDataModel
org.jdesktop.binding.DefaultDataModel
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:
- Construct the model using the Bean class you wish to model
- use
setJavaBean
to set the current object of this class.
- 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
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
propertyChangeListener
public java.beans.PropertyChangeListener propertyChangeListener
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 propertiesbean
- 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
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.