org.zkoss.zk.ui.sys
Class ComponentRedraws

java.lang.Object
  extended by org.zkoss.zk.ui.sys.ComponentRedraws

public class ComponentRedraws
extends java.lang.Object

Utilities to implement ComponentCtrl.redraw(java.io.Writer). Like HtmlPageRenders.getRenderContext(org.zkoss.zk.ui.Execution), they are used to simplify the implementation of the component rendering. However, there are some differences:

Since:
5.0.2
Author:
tomyeh

Constructor Summary
ComponentRedraws()
           
 
Method Summary
static java.lang.String afterRedraw()
          Called after finishing the redrawing.
static int beforeRedraw(boolean includingPage)
          Called before staring the redrawing.
static java.io.Writer getScriptBuffer()
          Returns the string buffer for the snippet that shall be generated after rendering the components.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentRedraws

public ComponentRedraws()
Method Detail

beforeRedraw

public static final int beforeRedraw(boolean includingPage)
Called before staring the redrawing. AbstractComponent.redraw(java.io.Writer) calls this method before calling AbstractComponent.renderProperties(org.zkoss.zk.ui.sys.ContentRenderer) and AbstractComponent.redrawChildren(java.io.Writer).

If this method is called, afterRedraw() must be called in the finally clause:

ComponentRedraws.beforeRedraw(false);
try {
  ...
} finally {
  ComponentRedraws.afterRedraw();
}

Parameters:
includingPage - whether this invocation is caused to include a new page. Unless for implementing an include component, this parameter shall be false.
Returns:
the order of redrawing of the component being redrawn among its siblings. If 0, it means it is the first sibling. If 1, it is the 2nd sibling. If -1, it means it is the top-level component in this redrawing. In other words, it is the component that ComponentCtrl.redraw(java.io.Writer) is called against.

getScriptBuffer

public static final java.io.Writer getScriptBuffer()
Returns the string buffer for the snippet that shall be generated after rendering the components. The content being added to the returned string buffer will be returned by afterRedraw() if it is called against the top-level component.


afterRedraw

public static final java.lang.String afterRedraw()
Called after finishing the redrawing. It must be called in the finally clause if beforeRedraw(boolean) is called.

Returns:
the snippet that shall be written to the HTML output. For HTML components, it is actually JavaScript snippet. To inject the snippet, just invoke getScriptBuffer() and append the snippet into the returned string buffer.
Notice that it always returns an empty string if it is not the top level.


Copyright © 2005-2011 Potix Corporation. All Rights Reserved. SourceForge.net Logo