zk
Class Skipper

java.lang.Object
  extended by zk.Object
      extended by zk.Skipper

public class Skipper
extends Object

A skipper is an object working with 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 = '',
 cap = this.caption;
 if (cap) html += cap.redraw();

 html += '
'; if (!skipper) for (var w = this.firstChild; w; w = w.nextSibling) if (w != cap) html += w.redraw(); return html + '
'; }

See also ZK Client-side Reference: Property Rendering.


Field Summary
static Skipper nonCaptionSkipper
          An instance of Skipper that can be used to skip the rerendering of child widgets except the caption.
 
Fields inherited from class zk.Object
$class, $oid
 
Method Summary
 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).
 
Methods inherited from class zk.Object
$init, $instanceof, $super, $super, $supers, $supers, afterInit, isAssignableFrom, isInstance, proxy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nonCaptionSkipper

public static Skipper nonCaptionSkipper
An instance of Skipper that can be used to skip the rerendering of child widgets except the caption.

It assumes

  1. The child widget not to skip can be found by the caption data member.
  2. The DOM elements to skip are child elements of the DOM element whose ID is widgetUUID$cave, where widgetUUID is the UUID of the widget being rerendered.

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);
 }
}

Method Detail

skipped

public boolean skipped(Widget wgt,
                       Widget child)
Returns whether the specified child widget will be skipped by skip(zk.Widget, _global_.String).

Default: returns if wgt.caption != child. In other words, it skip all children except the caption.

Parameters:
wgt - the widget to re-render
child - a child (descendant) of this widget.
Returns:
boolean

skip

public DOMElement skip(Widget wgt,
                       String skipId)
Skips all or subset of the descendant (child) widgets of the specified widget.

Notice that the

skipId
argument 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).

Parameters:
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.
Returns:
DOMElement

restore

public void restore(Widget wgt,
                    Object inf)
Restores the DOM elements that are detached (i.e., skipped) by skip(zk.Widget, _global_.String).

Parameters:
wgt - the widget being re-rendered
inf - 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 skipped


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