public class ObjectExporter extends AbstractObjectExporter implements PropertyChangeListener, Disposable
The object exporter is attached to a bean using attachTarget(Object)
and reads out the initial state of the bean and tries to subscribe to the
bean using the method
addPropertyChangeListener
. Changes announced by the bean will then be
reflected in the data items of the exporter.
The difference to the StaticObjectExporter
is, that the bean class
type must not be known in advance and data items will be created on the fly
based on the provided target object. If the target bean does not provide the
addPropertyChangeListener
method it still shows the state the target
bean had on attaching but will not update. Attaching to a new target object
is more expensive using the ObjectExporter
since all data items will
be destroyed in the process.
attributes, factory, items
Constructor and Description |
---|
ObjectExporter(ItemFactory itemFactory)
Create a new object exporter
|
ObjectExporter(ItemFactory itemFactory,
boolean readOnly,
boolean nullIsError)
Create a new object exporter
|
ObjectExporter(ItemFactory itemFactory,
boolean readOnly,
boolean nullIsError,
String prefix)
Create a new object exporter
|
Modifier and Type | Method and Description |
---|---|
void |
attachTarget(Object target)
attach a new target.
|
void |
detachTarget()
detach from the current target if we have one
|
void |
dispose() |
protected void |
fillAttributes(PropertyDescriptor pd,
Map<String,Variant> attributes) |
protected Map<String,Variant> |
getAdditionalAttributes() |
protected Method |
getEventMethod(String methodName) |
protected Object |
getTarget()
Get the current target or
null if there is none |
void |
propertyChange(PropertyChangeEvent evt) |
void |
setAttributes(Map<String,Variant> additionalAttributes) |
createDataItems, findAnnotation, getOptions, initAttribute, makeItemName, updateAttribute, updateItemsFromTarget, writeAttribute
public ObjectExporter(ItemFactory itemFactory)
itemFactory
- the factory used to create items. This factory is disposed
when the object exporter is disposed.public ObjectExporter(ItemFactory itemFactory, boolean readOnly, boolean nullIsError, String prefix)
itemFactory
- the factory used to create items. This factory is disposed
when the object exporter is disposed.readOnly
- set to true
in order to make all items read-onlynullIsError
- set to true
to mark fields that are
null
with an error attributeprefix
- the prefix of the item idspublic ObjectExporter(ItemFactory itemFactory, boolean readOnly, boolean nullIsError)
itemFactory
- the factory used to create items. This factory is disposed
when the object exporter is disposed.readOnly
- set to true
in order to make all items read-onlynullIsError
- set to true
to mark fields that are
null
with an error attributepublic void attachTarget(Object target)
target
- the new targetprotected Map<String,Variant> getAdditionalAttributes()
getAdditionalAttributes
in class AbstractObjectExporter
protected void fillAttributes(PropertyDescriptor pd, Map<String,Variant> attributes)
fillAttributes
in class AbstractObjectExporter
public void detachTarget()
public void dispose()
dispose
in interface Disposable
dispose
in class AbstractObjectExporter
public void propertyChange(PropertyChangeEvent evt)
propertyChange
in interface PropertyChangeListener
protected Object getTarget()
AbstractObjectExporter
null
if there is nonegetTarget
in class AbstractObjectExporter