echopointng.ui.syncpeer
Class AbstractEchoPointPeer

java.lang.Object
  extended by echopointng.ui.syncpeer.AbstractEchoPointPeer
All Implemented Interfaces:
ComponentSynchronizePeer, DomUpdateSupport
Direct Known Subclasses:
AbstractEchoPointContainerPeer, ButtonExPeer, CalculatorPeer, DateChooserPeer, ImageIconPeer, ImageMapPeer, InvisiblePeer, KeyStrokeListenerPeer, ProgressBarPeer, RichTextAreaPeer, SeparatorPeer, StrutPeer, TreeTableCellPeer

public abstract class AbstractEchoPointPeer
extends java.lang.Object
implements DomUpdateSupport, ComponentSynchronizePeer

AbstractEchoPointPeer is a base class for peers that dont necessarily adhere to container semantics


Field Summary
protected static java.lang.String DEFAULT_CONTAINER_TAG
          This is the default tag used as a HTML container for child elements.
protected  PartialUpdateManager partialUpdateManager
          There is a PartialUpdateManager available for subclass peers to use to for partial update support By default it has an AblePartialUpdater added to it to handle echopoint.able.* interfaces as well as a background and foreground color partial update support.
 
Constructor Summary
AbstractEchoPointPeer()
          Constructs a AbstractEchoPointPeer
 
Method Summary
protected  void disposeRenderState(Component component)
          Called to dispose of any render state for a given component.
 java.lang.String getContainerId(Component child)
          Returns an identifier in the form "parentId_contains_childId".
 void renderAdd(RenderContext rc, ServerComponentUpdate update, java.lang.String targetId, Component component)
          This calls renderHtml() to render the entire peer output.
 void renderDispose(RenderContext rc, ServerComponentUpdate update, Component component)
          Removes any render state that is associated with the component.
 void renderHtml(RenderContext rc, ServerComponentUpdate update, org.w3c.dom.Node parentNode, Component component)
          This sets up the EchoPoint RenderingContext helper and then calls the abstract renderHtml method.
abstract  void renderHtml(RenderingContext rc, org.w3c.dom.Node parentNode, Component component)
          This is the rendering method you must implement if you are to use AbstractEchoPointPeer.
protected  org.w3c.dom.Element renderReplaceableChild(RenderContext rc, ServerComponentUpdate update, org.w3c.dom.Node parentNode, Component child)
          Renders an individual child component of the AbstractEchoPointPeer.
 boolean renderUpdate(RenderContext rc, ServerComponentUpdate update, java.lang.String targetId)
          This method ends up calling renderUpdateBaseImpl(rc, update, targetId, fullReplace) method with fullReplace as true.
protected  void renderUpdateAddChildren(RenderContext rc, ServerComponentUpdate update)
          Renders child components which were added to a AbstractEchoPointPeer, as described in the provided ServerComponentUpdate.
protected  boolean renderUpdateBaseImpl(RenderContext rc, ServerComponentUpdate update, java.lang.String targetId, boolean fullReplace)
          If a full replace is to be done then this will remove itself from the parent and redraw everything otherwise it will replace just the changed children.
protected  void renderUpdateRemoveChildren(RenderContext rc, ServerComponentUpdate update)
          Renders removal operations for child components which were removed from a AbstractEchoPointPeer, as described in the provided ServerComponentUpdate.
protected  RenderState retreiveRenderState(Component component)
          This retreives some RenderState using the Component as 'weak' key.
protected  void storeRenderState(Component component, RenderState renderState)
          This stores some RenderState 'weakly' against a a Component and also updates the RenderingContext to point the new rendering state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CONTAINER_TAG

protected static final java.lang.String DEFAULT_CONTAINER_TAG
This is the default tag used as a HTML container for child elements.

See Also:
Constant Field Values

partialUpdateManager

protected PartialUpdateManager partialUpdateManager
There is a PartialUpdateManager available for subclass peers to use to for partial update support

By default it has an AblePartialUpdater added to it to handle echopoint.able.* interfaces as well as a background and foreground color partial update support.

Constructor Detail

AbstractEchoPointPeer

public AbstractEchoPointPeer()
Constructs a AbstractEchoPointPeer

Method Detail

getContainerId

public java.lang.String getContainerId(Component child)
Returns an identifier in the form "parentId_contains_childId".

Specified by:
getContainerId in interface ComponentSynchronizePeer
Parameters:
child - a Component whose parent is of the type synchronized by this peer object.
Returns:
the id of the element which should contain the child component's rendered HTML.
See Also:
nextapp.echo2.webcontainer.SynchronizePeer#getContainerId(nextapp.echo2.app.Component)

renderDispose

public void renderDispose(RenderContext rc,
                          ServerComponentUpdate update,
                          Component component)
Removes any render state that is associated with the component.

Remember to call super.renderDispose() if you overrride this method.

Specified by:
renderDispose in interface ComponentSynchronizePeer
Parameters:
rc - the relevant RenderContext
update - the ServerComponentUpdate for which this operation is being performed
See Also:
nextapp.echo2.webcontainer.SynchronizePeer#renderDispose(nextapp.echo2.webcontainer.RenderContext, nextapp.echo2.app.update.ServerComponentUpdate, nextapp.echo2.app.Component)

renderAdd

public void renderAdd(RenderContext rc,
                      ServerComponentUpdate update,
                      java.lang.String targetId,
                      Component component)
This calls renderHtml() to render the entire peer output.

Specified by:
renderAdd in interface ComponentSynchronizePeer
Parameters:
rc - the relevant RenderContext
update - the ServerComponentUpdate for which this operation is being performed
targetId - the id of the HTML element in which the component's HTML output should be rendered
component - the component to be rendered (this component must be of a type supported by this synchronization peer).
See Also:
nextapp.echo2.webcontainer.SynchronizePeer#renderAdd(nextapp.echo2.webcontainer.RenderContext, nextapp.echo2.app.update.ServerComponentUpdate, java.lang.String, nextapp.echo2.app.Component)

renderUpdate

public boolean renderUpdate(RenderContext rc,
                            ServerComponentUpdate update,
                            java.lang.String targetId)
This method ends up calling renderUpdateBaseImpl(rc, update, targetId, fullReplace) method with fullReplace as true. In other words by default it does coarse grain replacement of children.

Specified by:
renderUpdate in interface ComponentSynchronizePeer
Parameters:
rc - the relevant RenderContext
update - the ServerComponentUpdate for which this operation is being performed
targetId - the id of the HTML element inside of which the components HTML code should be rendered.
Returns:
true if updates to descendants should NOT be performed
See Also:
nextapp.echo2.webcontainer.SynchronizePeer#renderUpdate(nextapp.echo2.webcontainer.RenderContext, nextapp.echo2.app.update.ServerComponentUpdate, java.lang.String)

renderUpdateBaseImpl

protected boolean renderUpdateBaseImpl(RenderContext rc,
                                       ServerComponentUpdate update,
                                       java.lang.String targetId,
                                       boolean fullReplace)
If a full replace is to be done then this will remove itself from the parent and redraw everything otherwise it will replace just the changed children.

See Also:
nextapp.echo2.webcontainer.SynchronizePeer#renderUpdate(nextapp.echo2.webcontainer.RenderContext, nextapp.echo2.app.update.ServerComponentUpdate, java.lang.String)

renderUpdateAddChildren

protected void renderUpdateAddChildren(RenderContext rc,
                                       ServerComponentUpdate update)
Renders child components which were added to a AbstractEchoPointPeer, as described in the provided ServerComponentUpdate.

Parameters:
rc - the relevant RenderContext
update - the update

renderUpdateRemoveChildren

protected void renderUpdateRemoveChildren(RenderContext rc,
                                          ServerComponentUpdate update)
Renders removal operations for child components which were removed from a AbstractEchoPointPeer, as described in the provided ServerComponentUpdate.

Parameters:
rc - the relevant RenderContext
update - the update

renderReplaceableChild

protected org.w3c.dom.Element renderReplaceableChild(RenderContext rc,
                                                     ServerComponentUpdate update,
                                                     org.w3c.dom.Node parentNode,
                                                     Component child)
Renders an individual child component of the AbstractEchoPointPeer. It is deemed replaceable in the sense it gets enveloped in a tag container and hence can be DOM replaced directly via the Echo2 framework.

Each child in an HTML element tag of DEFAULT_CONTAINER_TAG and then renders the child component into it.

Parameters:
rc - the relevant RenderContext
update - the ServerComponentUpdate being performed
parentNode - a document fragment to hold the new XHTML
child - the child Component to be rendered
Returns:
- the new Element that has been used to surround the replaceable child component.

renderHtml

public void renderHtml(RenderContext rc,
                       ServerComponentUpdate update,
                       org.w3c.dom.Node parentNode,
                       Component component)
This sets up the EchoPoint RenderingContext helper and then calls the abstract renderHtml method.

Specified by:
renderHtml in interface DomUpdateSupport
Parameters:
rc - the relevant RenderContext
update - the ServerComponentUpdate for which this rendering is being performed
parentNode - the parent DOM node to which this child should add HTML code
component - the Component to be rendered
See Also:
DomUpdateSupport.renderHtml(nextapp.echo2.webcontainer.RenderContext, nextapp.echo2.app.update.ServerComponentUpdate, org.w3c.dom.Node, nextapp.echo2.app.Component)

renderHtml

public abstract void renderHtml(RenderingContext rc,
                                org.w3c.dom.Node parentNode,
                                Component component)
This is the rendering method you must implement if you are to use AbstractEchoPointPeer.

Its a simpler wrapper for the standard one but provides some neato setup services that would otherwise be repeated over and over again.

Note the use of RenderingContext object instead of the standard Echo RenderContext as this provides more rich code facilities.

Parameters:
rc - - the RenderingContext to use
parentNode - - the parent Node to put content into
component - - the component in question
See Also:
nextapp.echo2.webcontainer.DomUpdateSupport#renderHtml(nextapp.echo2.webcontainer.RenderContext, nextapp.echo2.app.update.ServerComponentUpdate, org.w3c.dom.Element, nextapp.echo2.app.Component)

storeRenderState

protected void storeRenderState(Component component,
                                RenderState renderState)
This stores some RenderState 'weakly' against a a Component and also updates the RenderingContext to point the new rendering state.

Parameters:
component - - the component to use as a key
renderState - - the RenderState to store

retreiveRenderState

protected RenderState retreiveRenderState(Component component)
This retreives some RenderState using the Component as 'weak' key. This may return null if the component has gone out of JVM scope.

Parameters:
component - - the component to use as a key
Returns:
- the RenderState previously stored via storeRenderState()

disposeRenderState

protected void disposeRenderState(Component component)
Called to dispose of any render state for a given component.

Parameters:
component - - the component to dispose render state for