SPT Core API

com.sptci.echo2.binding
Class ModelUpdater<V,M>

java.lang.Object
  extended by com.sptci.echo2.binding.Updater<V,M>
      extended by com.sptci.echo2.binding.ModelUpdater<V,M>
Type Parameters:
V - The class name of the view component from which data is read.
M - The class name of the model object that is to be updated.
Direct Known Subclasses:
JDOModelUpdater

public class ModelUpdater<V,M>
extends Updater<V,M>

An updater used to update JavaBean objects from their associated UI containers.

Copyright 2006 Sans Pareil Technologies, Inc.

Version:
$Id: ModelUpdater.java 4553 2008-12-24 10:34:16Z rakesh $
Author:
Rakesh Vidyadharan 2006-02-08

Field Summary
 
Fields inherited from class com.sptci.echo2.binding.Updater
bean, logger, view
 
Constructor Summary
ModelUpdater(V view, M bean)
          Create a new instance with the specified UI container and java bean.
 
Method Summary
protected  String getFieldName(String name)
          Fetch the proper bean beanField name to use based upon the view beanField name.
protected  void processCollection(Map.Entry<String,Object> entry, Method method, String fieldName)
          Process collection fields in Updater.bean.
 void update()
          Update the fields of the Updater.bean with the data in similarly named fields in Updater.view.
protected  void updateField(String fieldName, Map.Entry<String,Object> entry)
          Update the corresponding beanField in the Updater.bean with the specified beanField name.
 
Methods inherited from class com.sptci.echo2.binding.Updater
beanValues, getBean, getView, setBean, setView, viewValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelUpdater

public ModelUpdater(V view,
                    M bean)
Create a new instance with the specified UI container and java bean.

Parameters:
view - The Updater.view to use.
bean - The Updater.bean to use.
Method Detail

update

public void update()
Update the fields of the Updater.bean with the data in similarly named fields in Updater.view.

Specified by:
update in class Updater<V,M>
Throws:
BindingException - If errors are encountered while accessing or setting the fields.
See Also:
ReflectionUtility.fetchField(java.lang.String, java.lang.Object), ReflectionUtility.fetchMethod(java.lang.reflect.Field, java.lang.String, java.lang.Class...)

getFieldName

protected String getFieldName(String name)
Fetch the proper bean beanField name to use based upon the view beanField name.

Parameters:
name - The view beanField name.
Returns:
The bean beanField name corresponding to the view beanField name.

updateField

protected void updateField(String fieldName,
                           Map.Entry<String,Object> entry)
                    throws IntrospectionException
Update the corresponding beanField in the Updater.bean with the specified beanField name.

Parameters:
fieldName - The name of the beanField in Updater.bean to update.
entry - The map entry with the name and value of the associated beanField in Updater.bean.
Throws:
IntrospectionException - If reflection errors occur.

processCollection

protected void processCollection(Map.Entry<String,Object> entry,
                                 Method method,
                                 String fieldName)
Process collection fields in Updater.bean. Collections are usually represented by AbstractListComponent instances.

Parameters:
entry - A map entry representing the name of the field in Updater.view and its value.
method - The method that is to be invoked on Updater.bean.
fieldName - The name of the field in Updater.bean that is being updated.

SPT Core API