net.xoetrope.xui.data
Class XStateBinding

java.lang.Object
  extended by net.xoetrope.xui.data.XStateBinding
All Implemented Interfaces:
XDataBinding

public class XStateBinding
extends java.lang.Object
implements XDataBinding

Bind a component's state to a data model value/node. The binding allows a model node to linked to a UI component so that it can be refreshed when new data is written to the model or conversely when the UI component needs to write data to the model.
This binding is designed to be used by components such as RadioButtons or Checkboxes.

This state change does not affect the content displayed by the component.

Copyright (c) Xoetrope Ltd., 1998-2003
License: see license.txt


Field Summary
protected  java.lang.String attribStr
           
protected  java.lang.Object comp
           
protected  boolean isLeafNode
           
protected  java.lang.String offValue
          The value which will be used to store the value of the off state of the check/radio components in the model.
protected  java.lang.String onValue
          The value which will be used to store the value of the on state of the check/radio components in the model.
protected  XModel outputModel
           
protected  java.lang.String outputPath
           
protected  XModel sourceModel
           
protected  java.lang.String srcPath
           
 
Fields inherited from interface net.xoetrope.xui.data.XDataBinding
DEFAULT_OUTPUT_PATH
 
Constructor Summary
XStateBinding()
          Default constuctor to enable creation of subclassed custom bindings and late binding.
XStateBinding(java.lang.Object c, java.lang.String dataElement)
          Construct a new data binding
XStateBinding(java.lang.Object c, java.lang.String dataElement, XModel srcModel, java.lang.String leafAttrib)
          Construct a new data binding
 
Method Summary
 void get()
          Updates the component state with the value obtained from the data model.
 java.lang.String getAttribute()
          Retrieve the name of the attribute which is storing the value of the binding
 java.lang.Object getComponent()
          Get the component to which this binding is attached
 java.lang.String getName()
          Gets the name of the model node
 java.lang.String getOutputPath()
          Get the model path for the output/state data
 java.lang.String getSourcePath()
          Get the model path for the source data
 void set()
          Updates the data model with the value retrieved from the component.
 void setAttribute(java.lang.String attrib)
          Set the name of the attribute which is to be used for storing and retrieving the model value.
 void setOutput(XModel newNode, java.lang.String outputPath)
          Update the path values stored by this node.
 void setOutputPath(java.lang.String newPath)
          Set the model path for the output/state data
 void setSource(XModel newNode)
          Update the model node used in the binding.
 void setSourcePath(java.lang.String newPath)
          Set the model path for the source data
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

comp

protected java.lang.Object comp

sourceModel

protected XModel sourceModel

outputModel

protected XModel outputModel

srcPath

protected java.lang.String srcPath

outputPath

protected java.lang.String outputPath

isLeafNode

protected boolean isLeafNode

attribStr

protected java.lang.String attribStr

onValue

protected java.lang.String onValue
The value which will be used to store the value of the on state of the check/radio components in the model.


offValue

protected java.lang.String offValue
The value which will be used to store the value of the off state of the check/radio components in the model.

Constructor Detail

XStateBinding

public XStateBinding()
Default constuctor to enable creation of subclassed custom bindings and late binding.


XStateBinding

public XStateBinding(java.lang.Object c,
                     java.lang.String dataElement)
Construct a new data binding

Parameters:
c - the component to be bound
dataElement - the name of the data in the model

XStateBinding

public XStateBinding(java.lang.Object c,
                     java.lang.String dataElement,
                     XModel srcModel,
                     java.lang.String leafAttrib)
Construct a new data binding

Parameters:
c - the component to be bound
dataElement - the name of the data in the model
srcModel - the model node that acts as the data source for this node
leafAttrib - null or true for a leaf node where the value controls the state, or false to use the child values to control not only the state but also the enabled/disabled state
Method Detail

setAttribute

public void setAttribute(java.lang.String attrib)
Set the name of the attribute which is to be used for storing and retrieving the model value.

Parameters:
attrib - the name of the attribute which will store the value.

getAttribute

public java.lang.String getAttribute()
Retrieve the name of the attribute which is storing the value of the binding


get

public void get()
Updates the component state with the value obtained from the data model.

Specified by:
get in interface XDataBinding

set

public void set()
Updates the data model with the value retrieved from the component.

Specified by:
set in interface XDataBinding

getComponent

public java.lang.Object getComponent()
Get the component to which this binding is attached

Specified by:
getComponent in interface XDataBinding
Returns:
The component which is being bound

getSourcePath

public java.lang.String getSourcePath()
Get the model path for the source data

Specified by:
getSourcePath in interface XDataBinding
Returns:
The raw path to which the source model is bound

getOutputPath

public java.lang.String getOutputPath()
Get the model path for the output/state data

Specified by:
getOutputPath in interface XDataBinding
Returns:
The raw path to which the output model is bound

setSource

public void setSource(XModel newNode)
Update the model node used in the binding. Note that this method does not modify the path values stored by this node.

Specified by:
setSource in interface XDataBinding
Parameters:
newNode - the new model for the data source

setOutput

public void setOutput(XModel newNode,
                      java.lang.String outputPath)
Update the path values stored by this node. The output path is used to store selection data and state.

Specified by:
setOutput in interface XDataBinding
Parameters:
newNode - the new model for saving the output data
outputPath - The path to which the outputModel is writing.

setSourcePath

public void setSourcePath(java.lang.String newPath)
Set the model path for the source data

Specified by:
setSourcePath in interface XDataBinding
Parameters:
newPath - The path to which the source model is to be bound

setOutputPath

public void setOutputPath(java.lang.String newPath)
Set the model path for the output/state data

Specified by:
setOutputPath in interface XDataBinding
Parameters:
newPath - The path to which the output model is to be bound

getName

public java.lang.String getName()
Gets the name of the model node

Returns:
the name