net.xoetrope.xui.data
Class XListBinding

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

public class XListBinding
extends java.lang.Object
implements XDataBinding

Bind a list to a data model value/node. The binding allows a list 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 list like components such as comboboxes or drop down lists.

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


Field Summary
protected  java.lang.String attribStr
           
protected  boolean bDirty
           
protected  XListHolder comp
           
protected  XListModelAdapter model
           
protected  XModel outputNode
           
protected  java.lang.String outputPath
           
protected  boolean saveToSourceNode
           
protected  java.lang.String srcPath
           
protected  boolean useUnique
           
 
Fields inherited from interface net.xoetrope.xui.data.XDataBinding
DEFAULT_OUTPUT_PATH
 
Constructor Summary
XListBinding()
          null ctor
XListBinding(java.lang.Object c, java.lang.String dataElement)
          Construct a new data binding
XListBinding(java.lang.Object c, java.lang.String dataElement, java.lang.String destElement)
          Construct a new data binding
XListBinding(java.lang.Object c, java.lang.String dataElement, java.lang.String destElement, XModel srcModel, XModel dstModel)
          Construct a new data binding
XListBinding(java.lang.Object c, java.lang.String dataElement, java.lang.String destElement, XModel srcModel, XModel dstModel, java.lang.String attrib, boolean saveToSource)
          Construct a new data binding Set the languageResourceBundle for text to be translated
XListBinding(java.lang.Object c, java.lang.String dataElement, XModel srcModel)
          Construct a new data binding
XListBinding(java.lang.Object c, XModel node)
          Construct a new data binding
XListBinding(java.lang.Object c, XModelAdapter node)
          Construct a new data binding
 
Method Summary
protected  java.lang.String addItem(java.lang.String s)
          Add an item to the component.
 void get()
          Updates the TextComponent with the value obtained from the data model.
 java.lang.Object getComponent()
          Gets the component on which this binding operates
 boolean getDirty()
          Retrieve the dirty flag
 java.lang.String getName()
          Gets the name of the model node
 java.lang.String getOutputPath()
          Get the path to the model which is used for binding
 java.lang.String getSourcePath()
          Get the path to which the source model is bound
 void set()
          Updates the data model with the value retrieved from the TextComponent.
 void setDirty(boolean dirty)
          Set the dirty flag so that the list repopulates
 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 for this bindings's data
 void setSourcePath(java.lang.String newPath)
          Set the model path for the source data
 void setUseUnique(boolean isUnique)
          Set the list to use unique entries (remove duplicates)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

comp

protected XListHolder comp

model

protected XListModelAdapter model

outputNode

protected XModel outputNode

useUnique

protected boolean useUnique

bDirty

protected boolean bDirty

saveToSourceNode

protected boolean saveToSourceNode

srcPath

protected java.lang.String srcPath

outputPath

protected java.lang.String outputPath

attribStr

protected java.lang.String attribStr
Constructor Detail

XListBinding

public XListBinding()
null ctor


XListBinding

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

XListBinding

public XListBinding(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 model node that acts as the data source for this node

XListBinding

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

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

XListBinding

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

Parameters:
c - the component to be bound
dataElement - the name of the data in the model
destElement - the name of the destination data in the model
srcModel - the model node that acts as the data source for this node
dstModel - the model node to which the selection is saved

XListBinding

public XListBinding(java.lang.Object c,
                    java.lang.String dataElement,
                    java.lang.String destElement,
                    XModel srcModel,
                    XModel dstModel,
                    java.lang.String attrib,
                    boolean saveToSource)
Construct a new data binding Set the languageResourceBundle for text to be translated

Parameters:
c - the component to be bound
dataElement - the name of the data in the model
destElement - the name of the destination data in the model
srcModel - the model node that acts as the data source for this node
dstModel - the model node to which the selection is saved
attrib - the attribute of the model node to which the selection is saved
saveToSource - true to save the selected value as the value of the source node, false to save only to the output node

XListBinding

public XListBinding(java.lang.Object c,
                    XModel node)
Construct a new data binding

Parameters:
c - the component to be bound
node - the model node

XListBinding

public XListBinding(java.lang.Object c,
                    XModelAdapter node)
Construct a new data binding

Parameters:
c - the component to be bound
node - the model node
Method Detail

setDirty

public void setDirty(boolean dirty)
Set the dirty flag so that the list repopulates

Parameters:
dirty - the state for the dirty flag

getDirty

public boolean getDirty()
Retrieve the dirty flag

Returns:
the dirty flag

get

public void get()
Updates the TextComponent with the value obtained from the data model. Filters the list by ignoring repeat items (note that this does not guarantee unique list entries unless the useUnique flag is set).

Specified by:
get in interface XDataBinding

addItem

protected java.lang.String addItem(java.lang.String s)
Add an item to the component. In a separate method to aid with subclassing for localisation

Parameters:
s - The new item to be added to the list
Returns:
The passed string

set

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

Specified by:
set in interface XDataBinding

setUseUnique

public void setUseUnique(boolean isUnique)
Set the list to use unique entries (remove duplicates)

Parameters:
isUnique - teh new flag value

getComponent

public java.lang.Object getComponent()
Gets the component on which this binding operates

Specified by:
getComponent in interface XDataBinding
Returns:
the bound component

getName

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

Returns:
the name

getSourcePath

public java.lang.String getSourcePath()
Get the path to which the source model is bound

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

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 which is to be used by the source model

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 which is to be used by the output model

getOutputPath

public java.lang.String getOutputPath()
Get the path to the model which is used for binding

Specified by:
getOutputPath in interface XDataBinding
Returns:
The path which is being used by the output model

setSource

public void setSource(XModel newNode)
Set the source for this bindings's data

Specified by:
setSource in interface XDataBinding
Parameters:
newNode - the path to 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.