SPT Core API

com.sptci.echo2.binding
Class JDOModelUpdater<V,M extends JDOObject>

java.lang.Object
  extended by com.sptci.echo2.binding.Updater<V,M>
      extended by com.sptci.echo2.binding.ModelUpdater<V,M>
          extended by com.sptci.echo2.binding.JDOModelUpdater<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.

public class JDOModelUpdater<V,M extends JDOObject>
extends ModelUpdater<V,M>

An updater used to update JavaBean objects from their associated UI containers. Adds JDO specific actions such as making modifications within the bounds of a transaction.

The following shows sample use of this updater:

   import com.sptci.echo2.binding.JDOModelUpdater;

     ...
     // If persisting new instances to data store
     Bean bean = new Bean();
     bean.setName( "name" );
     bean.setDescription( "my name" );
     View view = new View( bean );
     // bind view from model and let user interact
     JDOModelUpdater updater = new JDOModeUpdater( view, bean );
     updater.update();

     ...
     // If updating persistent instances.
     Bean bean = BeanFactory.fetch( "name", pm );
     View view = new View( bean );
     // bind view from model and let user interact
     JDOModelUpdater updater = new JDOModelUpdater( view, bean );
     updater.update();
 

Copyright 2006 Sans Pareil Technologies, Inc.

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

Field Summary
protected  boolean active
          A flag used to indicate whether a transaction is active or not with the pm.
protected  NonTransactionalJDOApplication app
          The global application instance for the user session.
 
Fields inherited from class com.sptci.echo2.binding.Updater
bean, logger, view
 
Constructor Summary
JDOModelUpdater(V view, M bean)
          Create a new instance with the specified UI container and java bean.
 
Method Summary
protected  void begin()
          Initialise pm and start a transaction if necessary.
protected  void commit()
          Commit an existing trasaction associated with the pm if appropriate.
protected  Object getRepository()
          Fetch the repository instance to use to manage Updater.bean.
protected  void persist()
          Persist the Updater.bean to the data store.
protected  void rollback()
          Rollback the current transaction in case errors were encountered while interacting with the data store.
 void update()
          Over-ridden to conduct the updates with the bounds of a transaction as mandated by JDO.
 
Methods inherited from class com.sptci.echo2.binding.ModelUpdater
getFieldName, processCollection, updateField
 
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
 

Field Detail

app

protected final NonTransactionalJDOApplication app
The global application instance for the user session.


active

protected boolean active
A flag used to indicate whether a transaction is active or not with the pm.

Constructor Detail

JDOModelUpdater

public JDOModelUpdater(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()
Over-ridden to conduct the updates with the bounds of a transaction as mandated by JDO. Starts a new transaction is necessary and delegates processing to the super-class method implementation. This method is usually used for persistent bean instances.

Overrides:
update in class ModelUpdater<V,M extends JDOObject>
Throws:
BindingException - If errors are encountered while accessing or setting the fields.
See Also:
begin(), ModelUpdater.update(), persist()

begin

protected void begin()
Initialise pm and start a transaction if necessary.


persist

protected void persist()
                throws BindingException
Persist the Updater.bean to the data store. Invokes the save method on an associated repository class for Updater.bean or directly on pm.

Throws:
BindingException - If errors are encountered while introspecting the repository.
See Also:
getRepository()

commit

protected void commit()
Commit an existing trasaction associated with the pm if appropriate.


rollback

protected void rollback()
Rollback the current transaction in case errors were encountered while interacting with the data store.


getRepository

protected Object getRepository()
                        throws ClassNotFoundException,
                               Throwable
Fetch the repository instance to use to manage Updater.bean.

Returns:
The repository instance if a standard instance exists.
Throws:
ClassNotFoundException - If the repository does not exist
Throwable - If other reflection errors are encountered.

SPT Core API