Package org.zkoss.zk.ui.sys
Class ComponentRedraws
java.lang.Object
org.zkoss.zk.ui.sys.ComponentRedraws
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:
beforeRedraw(boolean)andafterRedraw()can be called even without an execution (e.g., in a working thread).
- Since:
- 5.0.2
- Author:
- tomyeh
-
Method Summary
Modifier and TypeMethodDescriptionstatic final StringCalled after finishing the redrawing.static final intbeforeRedraw(boolean includingPage) Called before staring the redrawing.static final WriterReturns the string buffer for the snippet that shall be generated after rendering the components.static final voidInternal used onlystatic final voidInternal used only
-
Method Details
-
beforeRedraw
public static final int beforeRedraw(boolean includingPage) Called before staring the redrawing.AbstractComponent.redraw(java.io.Writer)calls this method before callingAbstractComponent.renderProperties(org.zkoss.zk.ui.sys.ContentRenderer)andAbstractComponent.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
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 byafterRedraw()if it is called against the top-level component. -
afterRedraw
Called after finishing the redrawing. It must be called in the finally clause ifbeforeRedraw(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
-