Class ComponentRedraws

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

public class ComponentRedraws extends 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
  • Method Details

    • 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 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 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.
    • saveStates

      public static final void saveStates()
      Internal used only
    • restoreStates

      public static final void restoreStates()
      Internal used only