to.etc.domui.dom.html
Class NodeContainer

java.lang.Object
  extended by to.etc.domui.dom.css.CssBase
      extended by to.etc.domui.dom.html.NodeBase
          extended by to.etc.domui.dom.html.NodeContainer
All Implemented Interfaces:
java.lang.Iterable<NodeBase>, IModelBinding, INodeErrorDelegate
Direct Known Subclasses:
ATag, Button, Div, Form, HTag, InputNodeContainer, Label, Li, SelectOption, Span, Table, TBody, TD, THead, TR, Ul

public abstract class NodeContainer
extends NodeBase
implements java.lang.Iterable<NodeBase>

Base node for tags that can contain other nodes. A description on the deltaing mechanism used can be found in the header for NodeBase

Author:
Frits Jalvingh Created on Aug 17, 2007
See Also:
NodeBase

Constructor Summary
NodeContainer(java.lang.String tag)
          Create a container with the specified tag name.
 
Method Summary
 void add(int index, NodeBase nd)
          Add the child at the specified index in the child list.
 void add(NodeBase nd)
          Add the child at the end of the list.
 void add(java.lang.String txt)
          Add a #text node.
 TBody addTable(java.lang.String... headers)
          Utility method to add a table; it returns the TBody.
protected  void canContain(NodeBase node)
          Override to check if special node types can be contained in this.
protected  void delegateTo(NodeContainer c)
           
 int findChildIndex(NodeBase b)
          Return the index of the specified child, if present.
 void forceRebuild()
          This destroys all existing nodes and causes this node to be rebuilt the next time the tree is rendered.
 NodeBase getChild(int i)
          Get the nth child.
 int getChildCount()
          Return the #of children of this container.
<T> java.util.List<T>
getChildren(java.lang.Class<T> ofClass)
          Locate all direct children of this container that are instancesof [ofClass].
<T> T
getDeepChild(java.lang.Class<T> ofClass, int instance)
          Deprecated. 
<T> java.util.List<T>
getDeepChildren(java.lang.Class<T> ofClass)
          Get a list of all children in the entire subtree that are an instance of the specified class.
 IErrorFence getErrorFence()
           
 void internalCheckNotDirty()
          Used for unit tests.
 void internalClearDelta()
          DO NOT USE.
 void internalClearDeltaFully()
          DO NOT USE.
 NodeBase[] internalGetOldChildren()
          Internal: delta renderer old children set if this node changed.
protected  void internalShelve()
           
protected  void internalUnshelve()
           
 java.util.Iterator<NodeBase> iterator()
          Return an iterator that iterates over all children, in order.
 void moveControlToModel()
          EXPERIMENTAL - DO NOT USE.
 void moveModelToControl()
          EXPERIMENTAL - DO NOT USE.
protected  void onRefresh()
          Default onRefresh for a container will call refresh on all children.
 void removeAllChildren()
          Discard all children.
 NodeBase removeChild(int index)
          Remove the nth child.
 void removeChild(NodeBase child)
          Remove a child node from me.
 void replaceChild(NodeBase child, NodeBase nw)
          Swap two children: the "child" (1st) parameter gets removed, and the "nw" (2nd) parameter is put in it's place, at it's position.
 void setControlsEnabled(boolean on)
          EXPERIMENTAL - DO NOT USE.
 void setErrorFence()
           
 void setErrorFence(IErrorFence errorFence)
           
 void setText(java.lang.String txt)
          Set the text contained in this node, using tilde replacement.
<T,C extends IConverter<T>>
void
setValue(java.lang.Class<C> conv, T value)
          Put a converted value in this cell's text.
 
Methods inherited from class to.etc.domui.dom.html.NodeBase
$, acceptRequestParameter, addCssClass, addGlobalMessage, afterCreateContent, appendAfterMe, appendBeforeMe, appendCreateJS, appendJavascript, build, changed, clearFocusRequested, clearGlobalMessage, clearGlobalMessage, clearGlobalMessage, clearMessage, componentHandleWebAction, createContent, findComponentBundle, getActualID, getClicked, getComponentBundle, getCreateJS, getCssClass, getErrorDelegate, getErrorLocation, getMessage, getOnClickJS, getOnMouseDownJS, getPage, getParent, getParent, getParent, getSharedContext, getSpecialAttribute, getSpecialAttributeList, getTag, getTestID, getTitle, getUserObject, handleDrop, hasCssClass, hasError, internalGetOldParent, internalHasChangedAttributes, internalNeedClickHandler, internalOnClicked, internalSetHasChangedAttributes, internalSetHasChangedAttributes, internalSetTag, isBuilt, isFocusRequested, onAddedToPage, onBeforeFullRender, onForceRebuild, onHeaderContributors, onRemoveFromPage, onShelve, onUnshelve, refresh, remove, removeCssClass, renderJavascriptState, replaceWith, setClicked, setComponentBundle, setCssClass, setErrorDelegate, setErrorLocation, setFocus, setMessage, setOnClickJS, setOnMouseDownJS, setSpecialAttribute, setTestID, setTitle, setUserObject, stretchHeight, toString, visit
 
Methods inherited from class to.etc.domui.dom.css.CssBase
getBackgroundAttachment, getBackgroundColor, getBackgroundImage, getBackgroundPosition, getBackgroundRepeat, getBorderBottomColor, getBorderBottomStyle, getBorderBottomWidth, getBorderLeftColor, getBorderLeftStyle, getBorderLeftWidth, getBorderRightColor, getBorderRightStyle, getBorderRightWidth, getBorderTopColor, getBorderTopStyle, getBorderTopWidth, getBottom, getCachedStyle, getClear, getColor, getDisplay, getFloat, getFontFamily, getFontSize, getFontSizeAdjust, getFontStyle, getFontVariant, getFontWeight, getHeight, getLeft, getLineHeight, getMarginBottom, getMarginLeft, getMarginRight, getMarginTop, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOverflow, getPosition, getRight, getTextAlign, getTop, getTransform, getVerticalAlign, getVisibility, getWidth, getZIndex, internalSetDisplay, setBackgroundAttachment, setBackgroundColor, setBackgroundImage, setBackgroundPosition, setBackgroundRepeat, setBorder, setBorder, setBorderBottomColor, setBorderBottomStyle, setBorderBottomWidth, setBorderColor, setBorderLeftColor, setBorderLeftStyle, setBorderLeftWidth, setBorderRightColor, setBorderRightStyle, setBorderRightWidth, setBorderStyle, setBorderTopColor, setBorderTopStyle, setBorderTopWidth, setBorderWidth, setBottom, setBottom, setCachedStyle, setClear, setColor, setDisplay, setFloat, setFontFamily, setFontSize, setFontSizeAdjust, setFontStyle, setFontVariant, setFontWeight, setHeight, setLeft, setLeft, setLineHeight, setMargin, setMarginBottom, setMarginLeft, setMarginRight, setMarginTop, setMaxHeight, setMaxWidth, setMinHeight, setMinWidth, setOverflow, setPosition, setRight, setRight, setTextAlign, setTop, setTop, setTransform, setVerticalAlign, setVisibility, setWidth, setZIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NodeContainer

public NodeContainer(@Nonnull
                     java.lang.String tag)
Create a container with the specified tag name.

Parameters:
tag -
Method Detail

internalCheckNotDirty

public final void internalCheckNotDirty()
Used for unit tests.


internalClearDelta

public final void internalClearDelta()
DO NOT USE. Internal: clear all delta information.

Overrides:
internalClearDelta in class NodeBase
See Also:
NodeBase.internalClearDelta()

internalClearDeltaFully

public final void internalClearDeltaFully()
DO NOT USE. Internal: clear delta including children's delta.

Overrides:
internalClearDeltaFully in class NodeBase
See Also:
NodeBase.internalClearDeltaFully()

internalGetOldChildren

public final NodeBase[] internalGetOldChildren()
Internal: delta renderer old children set if this node changed. Null if this node has not seen changes.

Returns:

iterator

@Nonnull
public final java.util.Iterator<NodeBase> iterator()
Return an iterator that iterates over all children, in order.

Specified by:
iterator in interface java.lang.Iterable<NodeBase>
See Also:
Iterable.iterator()

getChildCount

public final int getChildCount()
Return the #of children of this container.

Returns:

findChildIndex

public final int findChildIndex(@Nonnull
                                NodeBase b)
Return the index of the specified child, if present. Returns -1 if not found.

Parameters:
b -
Returns:

getChild

@Nonnull
public final NodeBase getChild(int i)
Get the nth child.

Parameters:
i -
Returns:

canContain

@OverridingMethodsMustInvokeSuper
protected void canContain(@Nonnull
                                                           NodeBase node)
Override to check if special node types can be contained in this.

Parameters:
node -

add

public final void add(@Nonnull
                      NodeBase nd)
Add the child at the end of the list.

Parameters:
nd -

add

public final void add(int index,
                      @Nonnull
                      NodeBase nd)
Add the child at the specified index in the child list.

Parameters:
index -
nd -

add

public final void add(@Nullable
                      java.lang.String txt)
Add a #text node.

Parameters:
txt -

removeChild

public final void removeChild(@Nonnull
                              NodeBase child)
Remove a child node from me. This also removes ALL descendants from the current page's view.

Parameters:
child -

removeChild

@Nonnull
public final NodeBase removeChild(int index)
Remove the nth child. The removed child is returned and can be reused (added) somewhere else.

Parameters:
index -
Returns:

replaceChild

public final void replaceChild(@Nonnull
                               NodeBase child,
                               @Nonnull
                               NodeBase nw)
Swap two children: the "child" (1st) parameter gets removed, and the "nw" (2nd) parameter is put in it's place, at it's position.

Parameters:
child -
nw -

removeAllChildren

public final void removeAllChildren()
Discard all children.


forceRebuild

@OverridingMethodsMustInvokeSuper
public final void forceRebuild()
This destroys all existing nodes and causes this node to be rebuilt the next time the tree is rendered.

Overrides:
forceRebuild in class NodeBase

setText

public void setText(@Nullable
                    java.lang.String txt)
Set the text contained in this node, using tilde replacement. If the string starts with a ~ it is assumed to be a key into the page's resource bundle. Before the new text node is added to the container the container will first be fully emptied, i.e. any contained node will be deleted. FIXME This must be renamed and made final.

Parameters:
txt -

internalShelve

protected final void internalShelve()
                             throws java.lang.Exception
Overrides:
internalShelve in class NodeBase
Throws:
java.lang.Exception

internalUnshelve

protected final void internalUnshelve()
                               throws java.lang.Exception
Overrides:
internalUnshelve in class NodeBase
Throws:
java.lang.Exception

addTable

public TBody addTable(java.lang.String... headers)
Utility method to add a table; it returns the TBody.

Parameters:
cssclass - When not null this is set as the css class for the TABLE tag.
Returns:

getChildren

public final <T> java.util.List<T> getChildren(@Nonnull
                                               java.lang.Class<T> ofClass)
Locate all direct children of this container that are instancesof [ofClass].

Type Parameters:
T -
Parameters:
ofClass -
Returns:

getDeepChildren

public final <T> java.util.List<T> getDeepChildren(@Nonnull
                                                   java.lang.Class<T> ofClass)
Get a list of all children in the entire subtree that are an instance of the specified class.

Type Parameters:
T -
Parameters:
ofClass -
Returns:

getDeepChild

@Deprecated
public final <T> T getDeepChild(@Nonnull
                                           java.lang.Class<T> ofClass,
                                           int instance)
Deprecated. 

Find the nth instance of a specific child class using a full depth traversal of this node's subtree. FIXME Very questionable- pending deletion.

Type Parameters:
T -
Parameters:
ofClass -
instance -
Returns:

moveControlToModel

public final void moveControlToModel()
                              throws java.lang.Exception
EXPERIMENTAL - DO NOT USE. For all bound controls that are contained in this container, move the value present in the control to the data model. This converts and validates each control value as per the defined converters and validators. This will always attempt to move all values even if some control fails; the exception for the first failed control is rethrown after all controls are moved.

Specified by:
moveControlToModel in interface IModelBinding
Overrides:
moveControlToModel in class NodeBase
Throws:
java.lang.Exception
See Also:
NodeBase.moveControlToModel()

moveModelToControl

public final void moveModelToControl()
                              throws java.lang.Exception
EXPERIMENTAL - DO NOT USE. For all bound controls that are contained in this container, move the value found in the model to the control so it can be edited. If setting a value into a control results in an error (Exception) this will terminate immediately with that exception (meaning data is not moved to the controls following the failed controls).

Specified by:
moveModelToControl in interface IModelBinding
Overrides:
moveModelToControl in class NodeBase
Throws:
java.lang.Exception
See Also:
NodeBase.moveModelToControl()

setControlsEnabled

public final void setControlsEnabled(boolean on)
EXPERIMENTAL - DO NOT USE.

Specified by:
setControlsEnabled in interface IModelBinding
Overrides:
setControlsEnabled in class NodeBase
See Also:
NodeBase.setControlsEnabled(boolean)

onRefresh

protected void onRefresh()
                  throws java.lang.Exception
Default onRefresh for a container will call refresh on all children.

Overrides:
onRefresh in class NodeBase
Throws:
java.lang.Exception
See Also:
NodeBase.onRefresh()

delegateTo

protected final void delegateTo(@Nullable
                                NodeContainer c)

setValue

public <T,C extends IConverter<T>> void setValue(@Nonnull
                                                 java.lang.Class<C> conv,
                                                 @Nullable
                                                 T value)
              throws java.lang.Exception
Put a converted value in this cell's text.

Type Parameters:
T -
C -
Parameters:
conv -
value -
Throws:
java.lang.Exception

getErrorFence

@Nullable
public final IErrorFence getErrorFence()

setErrorFence

public final void setErrorFence(@Nullable
                                IErrorFence errorFence)

setErrorFence

public final void setErrorFence()