org.formaria.aria
Class DataBindingContext

java.lang.Object
  extended by org.formaria.aria.DataBindingContext
Direct Known Subclasses:
PersistentDataBindingContext

public class DataBindingContext
extends java.lang.Object

A class used by Page to manage the data binding coordination

Copyright (c) Formaria Ltd., 2008

License: see license.txt

$Revision: 1.1 $


Field Summary
protected  PathEvaluator evaluator
           
 java.util.Vector modelBindings
          Vector of DataBinding Objects currently in use by the Page
 
Constructor Summary
DataBindingContext(DataBindingContext parent, PathEvaluator pathEvaluator)
          Creates a new instance of DataBindingContext
 
Method Summary
 void addBinding(DataBinding b, boolean doGet)
          Add a binding of a component to the data model.
 void addBindingContext(DataBindingContext context)
          Add a binding context to the data model.
 DataBinding getBinding(java.lang.Object targetComp)
          Find the data binding associated with a component
 DataBinding getBinding(java.lang.String targetPath)
          Find the data binding associated with a data source path
 java.util.Vector getBindings()
          Retrieve the Vector of DataBinding for the Page
 DataBindingContext getParent()
          Get the parent data binding context or null if none exists (as in the case of the root context).
 void removeBinding(DataBinding b)
          Remove a binding of a component to the data model.
 int saveBoundComponentValues()
          Save the component values to the model
 void updateBinding(DataBinding binding)
          Update the bound model node for the binding.
 int updateBindings()
          Iterate all of the bindings in the page to reflect the model state.
 int updateBoundComponentValues()
          Update the UI with values from the model
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

modelBindings

public java.util.Vector modelBindings
Vector of DataBinding Objects currently in use by the Page


evaluator

protected PathEvaluator evaluator
Constructor Detail

DataBindingContext

public DataBindingContext(DataBindingContext parent,
                          PathEvaluator pathEvaluator)
Creates a new instance of DataBindingContext

Method Detail

getBindings

public java.util.Vector getBindings()
Retrieve the Vector of DataBinding for the Page

Returns:
Vector of DataBinding

addBinding

public void addBinding(DataBinding b,
                       boolean doGet)
Add a binding of a component to the data model. If the page has already been activated this method will update the binding automatically.

Parameters:
b - the binding "param doGet do a get on the binding once it has been added

addBindingContext

public void addBindingContext(DataBindingContext context)
Add a binding context to the data model.

Parameters:
context - the binding context

removeBinding

public void removeBinding(DataBinding b)
Remove a binding of a component to the data model.

Parameters:
b - the binding

updateBindings

public int updateBindings()
Iterate all of the bindings in the page to reflect the model state.

Returns:
non zero if errors are detected

updateBinding

public void updateBinding(DataBinding binding)
Update the bound model node for the binding. First the output path is reevaluated and then updated by setting the output node. Then the source path is reevaluated and set. Evaluation of the paths allows derived classes to dynamically modify the bindings. Some bindings may save the selection or state information to the output node and subsequently use it to restore the component state. This method does not alter the data held by the bound model nodes. To actually save the data use saveBoundComponentValues and to update the UI use updateBoundComponentValues.

Parameters:
binding - The databinding to be updated

updateBoundComponentValues

public int updateBoundComponentValues()
Update the UI with values from the model

Returns:
non zero if errors are detected

saveBoundComponentValues

public int saveBoundComponentValues()
Save the component values to the model

Returns:
non zero if errors are detected

getBinding

public DataBinding getBinding(java.lang.Object targetComp)
Find the data binding associated with a component

Parameters:
targetComp - the component whose binding is required
Returns:
the binding or null if no binding is found

getBinding

public DataBinding getBinding(java.lang.String targetPath)
Find the data binding associated with a data source path

Parameters:
targetPath - the path to the bound model
Returns:
the binding or null if no binding is found

getParent

public DataBindingContext getParent()
Get the parent data binding context or null if none exists (as in the case of the root context). Unlike exitDataBindingContext this method does not change the current data binding context

Returns:
the parent data binding context.