net.xoetrope.xui.data
Class XTextBinding

java.lang.Object
  extended by net.xoetrope.xui.data.XTextBinding
All Implemented Interfaces:
XDataBinding
Direct Known Subclasses:
XTextTableBinding

public class XTextBinding
extends java.lang.Object
implements XDataBinding

Bind a TextComponent 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 TextComponents or TextFields.

For a text component the source and destination area synonymous.

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


Field Summary
protected  java.lang.String attribStr
           
protected  java.lang.Object comp
           
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
XTextBinding()
          null ctor
XTextBinding(java.lang.Object c, java.lang.String dataElement)
          Construct a new data binding
XTextBinding(java.lang.Object c, java.lang.String dataElement, XModel srcModel)
          Construct a new data binding
XTextBinding(java.lang.Object c, java.lang.String dataElement, XModel srcModel, java.lang.String attrib)
          Construct a new data binding
 
Method Summary
 void get()
          Updates the TextComponent with the value obtained from the data model.
 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 TextComponent.
protected  void setComponentValue(java.lang.String value)
           
protected  void setModelValue(java.lang.String value)
          Code moved from the set method to enable easier overloading.
 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)
          Set the source node for data in the model
 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

attribStr

protected java.lang.String attribStr
Constructor Detail

XTextBinding

public XTextBinding()
null ctor


XTextBinding

public XTextBinding(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

XTextBinding

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

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

XTextBinding

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

Parameters:
c - the component to be bound
dataElement - the name of the data in the model
srcModel - the source model node
attrib - display an attribute of the source node if non null
Method Detail

get

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

Specified by:
get in interface XDataBinding

setComponentValue

protected void setComponentValue(java.lang.String value)

set

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

Specified by:
set in interface XDataBinding

setModelValue

protected void setModelValue(java.lang.String value)
Code moved from the set method to enable easier overloading. The default behaviour is to receive the value from the XTextHolder component but in the case where the model needs to be updated on an index value instead of the text for example, the subclassed binding can overload the set method and call setModelValue with the appropriate value.

Parameters:
value - the value to be stored in the model.

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)
Set the source node for data in the model

Specified by:
setSource in interface XDataBinding
Parameters:
newNode - the path of the data in the model

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