public class Skipper extends Object
Widget.rerender(int)
to rerender portion(s) of a widget (rather than the whole widget).
It can improve the performance a lot if it can skip a lot of portions, such as a lot of child widgets.
The skipper decides what to skip (i.e., not to rerender), detach the skipped portion(s), and attach them back after rerendering. Thus, the skipped portion won't be rerendered, nor unbound/bound.
The skipper has to implement three methods, skipped(zk.Widget, zk.Widget)
,
skip(zk.Widget, _global_.String)
and restore(zk.Widget, zk.Object)
. skipped(zk.Widget, zk.Widget)
is used to test whether a child widget shall be skipped.
skip(zk.Widget, _global_.String)
and restore(zk.Widget, zk.Object)
works together to detach and attach the skipped portions from the DOM tree. Here is how
Widget.rerender(int)
uses these two methods:
rerender: function (skipper) {
var skipInfo;
if (skipper) skipInfo = skipper.skip(this);
this.replaceHTML(this.node, null, skipper);
if (skipInfo) skipper.restore(this, skipInfo);
}
Since Widget.rerender(int)
will pass the returned value of skip(zk.Widget, _global_.String)
to restore(zk.Widget, zk.Object)
, the skipper doesn't need to store what are skipped. That means, it is possible to have one skipper to serve many widgets. nonCaptionSkipper
is a typical example.
In additions to passing a skipper to Widget.rerender(int)
, the widget has to implement the mold method to handle the skipper:
function (skipper) {
var html = '<fieldset' + this.domAttrs_() + '>',
cap = this.caption;
if (cap) html += cap.redraw();
html += '<div id="' + this.uuid + '$cave"' + this._contentAttrs() + '>';
if (!skipper)
for (var w = this.firstChild; w; w = w.nextSibling)
if (w != cap) html += w.redraw();
return html + '</div></fieldset>';
}
Modifier and Type | Field and Description |
---|---|
static Skipper |
nonCaptionSkipper
An instance of
Skipper that can be used to skip the rerendering of child widgets except the caption. |
Modifier and Type | Method and Description |
---|---|
void |
restore(Widget wgt,
Object inf)
Restores the DOM elements that are detached (i.e., skipped) by
skip(zk.Widget, _global_.String) . |
DOMElement |
skip(Widget wgt,
String skipId)
Skips all or subset of the descendant (child) widgets of the specified widget.
|
boolean |
skipped(Widget wgt,
Widget child)
Returns whether the specified child widget will be skipped by
skip(zk.Widget, _global_.String) . |
$init, $instanceof, $super, $super, $supers, $supers, afterInit, isAssignableFrom, isInstance, proxy
public static Skipper nonCaptionSkipper
Skipper
that can be used to skip the rerendering of child widgets except the caption.
It assumes
In other words, it detaches (i.e., skipped) all DOM elements under widget.$n('cave').
setClosable: function (closable) {
if (this._closable != closable) {
this._closable = closable;
if (this.node) this.rerender(zk.Skipper.nonCaptionSkipper);
}
}
public boolean skipped(Widget wgt, Widget child)
skip(zk.Widget, _global_.String)
.
Default: returns if wgt.caption != child. In other words, it skip all children except the caption.
wgt
- the widget to re-renderchild
- a child (descendant) of this widget.public DOMElement skip(Widget wgt, String skipId)
Notice that the
skipIdargument is not used by
Widget.rerender(int)
.
Rather it is used to simplify the overriding of this method,
such that the deriving class can call back this class and
to pass a different ID to skip
If you don't want to pass a different ID (default: uuid + '-cave'),
you can ignore skipId
Object skip(zk.Widget wgt);
Default: it detaches all DOM elements whose parent element is
jq(skipId || (wgt.uuid + '-cave'), zk)
.
wgt
- the widget being rerendered.skipId
- [optional] the ID of the element where all its descendant
elements shall be detached by this method, and restored later by restore(zk.Widget, zk.Object)
.
If not specified, uuid + '-cave'
is assumed.public void restore(Widget wgt, Object inf)
skip(zk.Widget, _global_.String)
.wgt
- the widget being re-renderedinf
- the object being returned by skip(zk.Widget, _global_.String)
.
It depends on how a skipper is implemented. It is usually to carry the information about what are skippedCopyright © 2005-2023 Potix Corporation. All Rights Reserved.