public class Widget extends Object
Refer to ZK Component Development Essentials and ZK Client-side Reference for more information.
Notice that, unlike the component at the server, Desktop
and Page
are derived from zk.Widget. It means desktops, pages and widgets are in a widget tree.
Modifier and Type | Field and Description |
---|---|
Object |
$weave
The weave controller that is used by ZK Weaver.
|
static int |
auDelay
The default delay before sending an AU request when
fire(_global_.String, zk.Object, _global_.Map, int)
is called (and the server has an ARAP event listener registered). |
String |
autag
The AU tag of this widget.
|
int |
bindLevel
The bind level (readonly)
The level in the widget tree after this widget is bound to a DOM tree (
bind_(zk.Desktop, zk.Skipper, _global_.Array, boolean) ). |
String |
className
The class name of the widget.
|
Desktop |
desktop
The desktop that this widget belongs to (readonly).
|
Map |
effects_
A map of objects that are associated with this widget, and
they shall be removed when this widget is unbound (
unbind(zk.Skipper, boolean) ). |
Widget |
firstChild
The first child, or null if no child at all (readonly).
|
String |
id
The identifier of this widget, or null if not assigned (readonly).
|
boolean |
insertingBefore_
Indicates an invocation of
appendChild(zk.Widget, boolean) is made by
insertBefore(zk.Widget, zk.Widget) . |
boolean |
inServer
Whether this widget has a peer component (readonly).
|
Widget |
lastChild
The last child, or null if no child at all (readonly).
|
int |
nChildren
The number of children (readonly).
|
Widget |
nextSibling
The next sibling, or null if this widget is the last child (readonly).
|
Widget |
parent
The parent, or null if this widget has no parent (readonly).
|
Widget |
previousSibling
The previous sibling, or null if this widget is the first child (readonly).
|
String |
uuid
The UUID.
|
String |
widgetName
The widget name of the widget.
|
Modifier and Type | Method and Description |
---|---|
static Widget |
$(Object n,
Map opts)
Retrieves the widget.
|
Map |
$f()
Returns the map of all fellows of this widget.
|
Widget |
$f(String id)
Returns the fellow of the specified ID of the ID space that this widget belongs to.
|
Widget |
$f(String id,
boolean global)
Returns the fellow of the specified ID of the ID space that this widget belongs to.
|
void |
$init(Map props)
The constructor.
|
DOMElement |
$n()
Returns the DOM element that this widget is bound to.
|
DOMElement |
$n(String subId)
Returns the child element of the DOM element(s) that this widget is bound to.
|
Widget |
$o()
Returns the owner of the ID space that this widget belongs to,
or null if it doesn't belong to any ID space.
|
String |
$s()
Returns the sub zclass name that cache for this widget.
|
Service |
$service()
Returns the service instance from the current widget, if any.
|
protected void |
afterAnima_(boolean visible)
Invoked after an animation (e.g.,
jqzk.slideDown(zk.Widget, _global_.Map) ) has finished. |
protected void |
afterParentChanged_(Widget oldparent)
A callback called after the parent has been changed.
|
boolean |
appendChild(Widget child)
Append a child widget.
|
boolean |
appendChild(Widget child,
boolean ignoreDom)
Append a child widget with more control.
|
protected void |
beforeParentChanged_(Widget newparent)
A callback called before the parent is changed.
|
protected void |
beforeSendAU_(Widget wgt,
Event evt)
Callback before sending an AU request.
|
protected void |
bind_(Desktop dt,
Skipper skipper,
Array after,
boolean bindSelfOnly)
Callback when this widget is bound (aka., attached) to the DOM tree.
|
Widget |
bind(Desktop desktop,
Skipper skipper,
boolean bindSelfOnly)
Binds this widget.
|
protected void |
bindChildren_(Desktop dt,
Skipper skipper,
Array after)
Binds the children of this widget.
|
protected void |
bindDoubleTap_()
Bind double click event to the widget on tablet device.
|
void |
bindMissingAncestors(Desktop desktop,
Skipper skipper)
Recursively bind ancestors that are currently unbound (i.e., `desktop` is falsy).
|
protected void |
bindSwipe_()
Bind swipe event to the widget on tablet device.
|
protected void |
bindTapHold_()
Bind right click event to the widget on tablet device.
|
boolean |
canActivate(Map opts)
Checks if this widget can be activated (gaining focus and so on).
|
protected void |
cleanDrag_()
Cleans up the widget to make it un-draggable.
|
void |
clear()
Removes all children.
|
void |
clearCache()
Clears the cached nodes (by
$n(_global_.String) ). |
protected DOMElement |
cloneDrag_(Draggable drag,
Offset ofs)
Called to create the visual effect representing what is being dragged.
|
protected void |
deferRedraw_(Array out)
Utilities for handling the so-called render defer (
setRenderdefer(int) ). |
protected void |
deferRedrawHTML_(Array out)
Renders a fake DOM element that will replace with the correct element after
the deferring time is up.
|
void |
detach()
Removes this widget (from its parent).
|
protected void |
doBlur_(Event evt)
A utility to simplify the listening of
onBlur . |
protected void |
doClick_(Event evt)
Called when the user clicks on a widget or a child widget.
|
protected void |
doDoubleClick_(Event evt)
Called when the user double-clicks on a widget or a child widget.
|
protected void |
doFocus_(Event evt)
A utility to simplify the listening of
onFocus . |
protected void |
doKeyDown_(Event evt)
Called when the user presses down a key when this widget has the focus (
focus(int) ). |
protected void |
doKeyPress_(Event evt)
Called when the user presses a key when this widget has the focus (
focus(int) ). |
protected void |
doKeyUp_(Event evt)
Called when the user presses up a key when this widget has the focus (
focus(int) ). |
protected String |
domAttrs_(Map no)
Returns the HTML attributes that is used to generate DOM element of this widget.
|
protected String |
domClass_(Map no)
Returns the class name(s) used for the DOM element of this widget.
|
protected Widget |
domListen_(DOMElement node,
String evtnm,
Object fn,
String keyword)
Registers an DOM event listener for the specified DOM element (aka., node).
|
protected void |
doMouseDown_(Event evt)
Called when the user presses down the mouse button on this widget (or one of its child widget).
|
protected void |
doMouseMove_(Event evt)
Called when the user moves the mouse pointer over this widget (or one of its child widget).
|
protected void |
doMouseOut_(Event evt)
Called when the user moves the mouse pointer out of a widget (or one of its child widget).
|
protected void |
doMouseOver_(Event evt)
Called when the user moves the mouse pointer on top of a widget (or one of its child widget).
|
protected void |
doMouseUp_(Event evt)
Called when the user presses up the mouse button on this widget (or one of its child widget).
|
protected String |
domStyle_(Map no)
Returns the style used for the DOM element of this widget.
|
protected String |
domTextStyleAttr_()
Returns the style attribute that contains only the text related CSS styles.
|
protected String |
domTooltiptext_()
Returns the tooltiptext for generating the title attribute of the DOM element.
|
protected Widget |
domUnlisten_(DOMElement node,
String evtnm,
Object fn,
String keyword)
Un-registers an event listener for the specified DOM element (aka., node).
|
protected void |
doPaste_(Event evt)
Called when the user paste text to this widget which has been the focused (
focus(int) ). |
protected void |
doResizeScroll_()
Resize zul.Scrollbar size after child added/removed or hide/show.
|
protected void |
doRightClick_(Event evt)
Called when the user right-clicks on a widget or a child widget.
|
protected void |
doSelect_(Event evt)
Called when the user clicks or right-clicks on widget or a child widget.
|
protected void |
doSwipe_(Event evt)
Called when the user swipe left/right/up/down this widget.
|
protected void |
doTooltipOut_()
Called when the mouse is moved out of this widget.
|
protected void |
doTooltipOver_()
Called when the mouse is moved over this widget.
|
protected void |
dropEffect_(boolean over)
Called to have some visual effect when the user is dragging a widget over this widget and this widget is droppable.
|
protected void |
extraBind_(String uuid,
boolean add)
Associates UUID with this widget.
|
Event |
fire(String evtnm,
Object data,
Map opts,
int timeout)
Fire a widget event.
|
Event |
fireX(Event evt,
int timeout)
Fire a widget event.
|
protected boolean |
focus_(int timeout)
Called by
focus(int) to set the focus. |
boolean |
focus(int timeout)
Sets the focus to this widget.
|
void |
forcerender()
Forces the rendering if it is deferred.
|
Offset |
fromPageCoord(int x,
int y)
Converts a coordinate related to the browser window into the coordinate
related to this widget.
|
Object |
get(String name)
Retrieves a value from the specified property.
|
String |
getAction()
Returns the client-side action.
|
DOMElement |
getCaveNode()
Called by
insertChildHTML_(zk.Widget, zk.Widget, zk.Desktop) to find the location to place the DOM element of the child. |
Widget |
getChildAt(int j)
Return the child widget at the specified index.
|
int |
getChildIndex()
Returns the child index of this widget.
|
static Class |
getClass(String wgtnm)
Returns the class of the specified widget's name.
|
int |
getCssflex()
Returns whether using css flex in this component or not.
|
String |
getDraggable()
Returns the identifier of a draggable type for this widget, or null if not draggable.
|
protected String |
getDragMessage_()
Returns the message to show when an user is dragging this widget, or null if it prefers to clone the widget with
cloneDrag_(zk.Draggable, _global_.Offset) . |
DOMElement |
getDragNode()
Returns the DOM element of this widget that can be dragged.
|
protected Map |
getDragOptions_(Map map)
Returns the options used to instantiate
Draggable . |
protected Widget |
getDrop_(Widget dragged)
Returns the widget if it allows to drop the specified widget (being dragged), or null if not allowed.
|
String |
getDroppable()
Returns the identifier, or a list of identifiers of a droppable type for this widget, or null if not droppable.
|
static Array |
getElementsById(String id)
Returns all elements with the given ID.
|
static Array |
getElementsByName(String name)
Returns all elements with the given widget name.
|
protected DOMElement |
getFirstNode_()
Returns the first DOM element of this widget.
|
protected void |
getFloatZIndex_(DOMElement node)
Returns the z-index of a floating widget.
|
String |
getHeight()
Returns the height of this widget.
|
String |
getHflex()
Return horizontal flex hint of this widget.
|
String |
getId()
Returns the identifier of this widget, or null if not assigned.
|
String |
getLeft()
Returns the left of this widget.
|
String |
getMold()
Returns this widget's mold.
|
protected void |
getOldWidget_(DOMElement n)
Returns the widget associated with the given node element.
|
Page |
getPage()
Returns the page that this widget belongs to, or null if there is
no page available.
|
int |
getRenderdefer()
Returns the number of milliseconds before rendering this component
at the client.
|
String |
getSclass()
Returns the CSS class of this widget.
|
int |
getScrollLeft()
Returns the scroll left of the associated DOM element of this widget.
|
int |
getScrollTop()
Returns the scroll top of the associated DOM element of this widget.
|
String |
getStyle()
Returns the CSS style of this widget
|
int |
getTabindex()
Returns the tab order of this component.
|
DOMElement |
getTextNode()
Returns the DOM element that is used to hold the text, or null
if this widget doesn't show any text.
|
String |
getTooltiptext()
Returns the tooltip text of this widget.
|
String |
getTop()
Returns the top of this widget.
|
Widget |
getTopWidget()
Returns the top widget, which is the first floating ancestor,
or null if no floating ancestor.
|
String |
getVflex()
Returns vertical flex hint of this widget.
|
String |
getWidth()
Returns the width of this widget.
|
String |
getZclass()
Returns the ZK Cascading Style class(es) for this widget.
|
int |
getZIndex()
Returns the Z index.
|
Widget |
hide()
Makes this widget invisible.
|
protected boolean |
ignoreDescendantFloatUp_()
A widget call this function of its ancestor if it wants to know whether its ancestor prefer ignore float up event of it self.
|
protected boolean |
ignoreDrag_(Draggable pt)
Returns if the location that an user is trying to drag is allowed.
|
protected void |
initDrag_()
Initializes the widget to make it draggable.
|
boolean |
insertBefore(Widget child,
Widget sibling)
Inserts a child widget before the reference widget (the
sibling argument). |
protected void |
insertChildHTML_(Widget child,
Widget before,
Desktop desktop)
Inserts the HTML content generated by the specified child widget before the reference widget (the before argument).
|
static boolean |
isAutoId(String uuid)
Deprecated.
we cannot really detect at the client if UUID is generated automatically.
|
boolean |
isBinding()
Returns whether this widget is being bound to DOM.
|
protected boolean |
isFloating_()
Returns if this widget is floating.
|
boolean |
isListen(String evtnm,
Map opts)
Returns if a listener is registered for the specified event.
|
boolean |
isRealElement()
Returns whether the widget has its own element bound to HTML DOM tree.
|
boolean |
isRealVisible()
Returns if this widget is really visible, i.e., all ancestor widget and itself are visible.
|
boolean |
isRealVisible(Map opts)
Returns if this widget is really visible, i.e., all ancestor widget and itself are visible.
|
boolean |
isVisible()
Returns if this widget is visible
|
boolean |
isVisible(boolean strict)
Returns if this widget is visible
|
protected boolean |
isWatchable_(String name,
Widget p,
Map cache)
Returns if the given watch shall be fired for this widget.
|
Widget |
listen(Map infos,
int priority)
Registers listener(s) to the specified event.
|
protected void |
listenOnFitSize_()
Listens to onFitSize event.
|
protected static void |
mimicMouseDown_(Widget wgt,
boolean noFocusChange,
int which)
Called to mimic the mouse down event fired by the browser.
|
static Widget |
newInstance(String wgtnm,
Map props)
Creates a widget by specifying the widget name.
|
static String |
nextUuid()
Returns the next unique UUID for a widget.
|
void |
onAfterSize()
Called to fire the onAfterSize event.
|
protected void |
onChildAdded_(Widget child)
A callback called after a child has been added to this widget.
|
protected void |
onChildRemoved_(Widget child)
A callback called after a child has been removed to this widget.
|
protected void |
onChildRenderDefer_(Widget child)
A callback called after a child has been delay rendered.
|
protected void |
onChildReplaced_(Widget oldc,
Widget newc)
A callback called after a child has been replaced.
|
protected void |
onChildVisible_(Widget child)
A callback called after a child's visibility is changed
(i.e.,
setVisible(boolean) was called). |
protected void |
onDrop_(Draggable drag,
Event evt)
Called to fire the onDrop event.
|
void |
redraw(Array out)
Generates the HTML fragment for this widget.
|
protected String |
redrawHTML_(Skipper skipper,
boolean trim)
Returns the HTML fragment of this widget.
|
static void |
register(String clsnm,
boolean blankPreserved)
Registers a widget class.
|
boolean |
removeChild(Widget child)
Removes a child.
|
boolean |
removeChild(Widget child,
boolean ignoreDom)
Removes a child with more control.
|
protected void |
removeChildHTML_(Widget child,
boolean ignoreDom)
Removes the corresponding DOM content of the specified child.
|
protected void |
removeHTML_(Array n)
Removes the HTML DOM content.
|
protected void |
replaceCavedChildren_(String subId,
Array wgts,
String tagBeg,
String tagEnd)
Replaced the child widgets with the specified widgets.
|
protected void |
replaceChildHTML_(Widget child,
DOMElement n,
Desktop dt,
Skipper skipper)
Replaces the DOM element(s) of the specified child widget.
|
Widget |
replaceHTML(Object n,
Desktop desktop,
Skipper skipper)
Replaces the specified DOM element with the HTML content generated this widget.
|
void |
replaceWidget(Widget newwgt,
Skipper skipper)
Replaces this widget with the specified one.
|
Widget |
rerender(int timeout)
Re-renders after the specified time (milliseconds).
|
Widget |
rerender(Skipper skipper)
Re-renders the DOM element(s) of this widget.
|
protected Widget |
rerenderLater_()
A function that postpones the invoke of rerender function until all the cmds from server are processed.
|
protected void |
rerenderNow_(Skipper skipper)
Forces the delaied rerendering children or itself to do now.
|
Widget |
scrollIntoView()
Makes this widget visible in the browser window by scrolling ancestors up or down, if necessary.
|
protected void |
sendAU_(Event evt,
int timeout)
Sends an AU request to the server.
|
Widget |
set(String name,
Object value)
Sets a property.
|
Widget |
set(String name,
Object value,
Object extra)
Sets a property.
|
void |
setAction(String action)
Sets the client-side action.
|
Widget |
setChildren(Array children)
Appends an array of children.
|
void |
setCssflex(boolean enable)
Sets whether to use css flex in this component or not.
|
protected void |
setDomVisible_(DOMElement n,
boolean visible,
Map opts)
Changes the visibility of a child DOM content of this widget.
|
Widget |
setDraggable(String draggable)
Sets the identifier of a draggable type for this widget.
|
Widget |
setDroppable(String droppable)
Sets the identifier, or a list of identifiers of a droppable type for this widget.
|
protected Widget |
setFloating_(boolean floating,
Map opts)
Sets a status to indicate if this widget is floating.
|
protected void |
setFloatZIndex_(DOMElement node,
int zi)
Sets the z-index for a floating widget.
|
Widget |
setHeight(String height)
Sets the height of this widget.
|
void |
setHflex(String flex)
Sets horizontal flexibility hint of this widget.
|
Widget |
setId(String id)
Sets the identifier of this widget.
|
Widget |
setLeft(String left)
Sets the left of this widget.
|
void |
setListener(Array inf)
Sets a listener that can be unlistened easily.
|
void |
setListener(String evt,
Function fn)
Sets a listener
It is designed to be called from server.
|
void |
setListeners(Map infos)
Sets the listener a map of listeners.
|
Widget |
setMold(String mold)
Sets this widget's mold.
|
void |
setRenderdefer(int ms)
Sets the number of milliseconds before rendering this component
at the client.
|
Widget |
setSclass(String sclass)
Sets the CSS class of this widget.
|
Widget |
setScrollLeft(int the)
Sets the scroll left of the associated DOM element of this widget.
|
Widget |
setScrollTop(int the)
Sets the scroll top of the associated DOM element of this widget.
|
Widget |
setStyle(String style)
Sets the CSS style of this widget.
|
void |
setTabindex(int tabindex)
Sets the tab order of this component.
|
Widget |
setTooltiptext(String title)
Sets the tooltip text of this widget.
|
Widget |
setTop(String top)
Sets the top of this widget.
|
int |
setTopmost()
Makes this widget as topmost.
|
void |
setVflex(String flex)
Sets vertical flexibility hint of this widget.
|
Widget |
setVisible(boolean visible)
Sets whether this widget is visible.
|
Widget |
setWidth(String width)
Sets the width of this widget.
|
Widget |
setZclass(String zclass)
Sets the ZK Cascading Style class(es) for this widget.
|
Widget |
setZIndex(int zIndex,
Map opts)
Sets the Z index.
|
protected boolean |
shallChildROD_()
Returns whether a new child shall be ROD.
|
protected void |
shallFireSizedLaterWhenAddChd_()
Returns whether a widget should fireSized later when addChd was invoked
Default: false.
|
protected boolean |
shallIgnoreClick_(Event the)
Check whether to ignore the click which might be caused by
doClick_(zk.Event)
doRightClick_(zk.Event) , or doDoubleClick_(zk.Event) . |
Widget |
show()
Makes this widget visible.
|
Widget |
smartUpdate(String name,
Object value,
int timeout)
Smart-updates a property of the peer component associated with this widget, running at the server, with the specified value.
|
protected void |
unbind_(Skipper skipper,
Array after,
boolean keepRod)
Callback when a widget is unbound (aka., detached) from the DOM tree.
|
Widget |
unbind(Skipper skipper,
boolean keepRod)
Unbinds this widget.
|
protected void |
unbindChildren_(Skipper skipper,
Array after,
boolean keepRod)
Unbinds the children of this widget.
|
protected void |
unbindDoubleTap_()
Unbind double click event to the widget on tablet device.
|
protected void |
unbindSwipe_()
Unbind swipe event to the widget on tablet device.
|
protected void |
unbindTapHold_()
Unbind right click event to the widget on tablet device.
|
protected void |
uncloneDrag_(Draggable drag)
Undo the visual effect created by
cloneDrag_(zk.Draggable, _global_.Offset) . |
Widget |
unlisten(Map infos)
Removes a listener from the specified event.
|
protected void |
unlistenOnFitSize_()
Unlistens to onFitSize event.
|
protected void |
updateDomClass_()
Updates the DOM element's CSS class.
|
protected void |
updateDomStyle_()
Updates the DOM element's style.
|
static String |
uuid(String subId)
Converts an ID of a DOM element to UUID.
|
void |
zsync(Map opts)
Synchronizes a map of objects that are associated with this widget, and
they shall be resized when the size of this widget is changed.
|
$init, $instanceof, $super, $super, $supers, $supers, afterInit, isAssignableFrom, isInstance, proxy
public int nChildren
public int bindLevel
bind_(zk.Desktop, zk.Skipper, _global_.Array, boolean)
).
For example, a widget's bind level is one plus the parent widget's
It starts at 0 if it is the root of the widget tree (a desktop, zk.Desktop), then 1 if a child of the root widget, and son on. Notice that it is -1 if not bound.
It is mainly useful if you want to maintain a list that parent widgets is in front of (or after) child widgets. bind level.
public String className
Notice that it is available if a widget class is loaded by WPD loader (i.e., specified in zk.wpd). If you create a widget class dynamically,
you have to invoke register(_global_.String, boolean)
to make this member available.
On the other hand, Object.$class
is available for all objects
extending from Object
.
widgetName
public String widgetName
this.className.substring(this.className.lastIndexOf('.') + 1).toLowerCase()
.
For example, if className
is zul.wnd.Window, then
widgetName
is window.
Notice that className
is unique while widgetName
is not necessary unique.
className
public String autag
xxx,yyy
and the desktop's
request path (Desktop.requestPath
) is /foo.zul
, then
the URL of the AU request will contain /_/foo.zul/xxx,yyy
,.
Default: null.
public Widget firstChild
getChildAt(int)
public Widget lastChild
getChildAt(int)
public Widget parent
public Widget nextSibling
public Widget previousSibling
public Desktop desktop
Notice it is always non-null if bound to the DOM tree, while
$n()
is always non-null if bound. For example, Timer
.
It is readonly, and set automatically when bind_(zk.Desktop, zk.Skipper, _global_.Array, boolean)
is called.
public String id
getId()
.
To change the value, use setId(_global_.String)
.
the ID
public boolean inServer
new zul.inp.Textox()
).public String uuid
inServer
is true.
Developers rarely need to modify it since it is generated automatically.public boolean insertingBefore_
appendChild(zk.Widget, boolean)
is made by
insertBefore(zk.Widget, zk.Widget)
.public Map effects_
unbind(zk.Skipper, boolean)
).
The key must be an unique name of the object, while the value must be an object that implement the destroy method.
When unbind_(zk.Skipper, _global_.Array, boolean)
is called, destroy()
is
called for each object stored in this map. Furthermore,
if the visibility of this widget is changed, and the object implements
the sync method, then sync()
will be called.
Notice that the sync method is optional. It is ignored if not implemented.
It is useful if you implement an effect, such as shadow, mask and error message, that is tightly associated with a widget.
public Object $weave
public static int auDelay
fire(_global_.String, zk.Object, _global_.Map, int)
is called (and the server has an ARAP event listener registered).
Default: 38 (Unit: miliseconds).
public String getMold()
public Widget setMold(String mold)
Default: default
mold
- the moldpublic String getStyle()
setStyle(_global_.String)
,
getSclass()
,
getZclass()
public Widget setStyle(String style)
Default: null
style
- the CSS stylegetStyle()
,
setSclass(_global_.String)
,
setZclass(_global_.String)
public String getSclass()
setSclass(_global_.String)
,
getZclass()
,
getStyle()
public Widget setSclass(String sclass)
Default: null.
The default styles of ZK components doesn't depend on sclass at all. Rather, setSclass is provided to perform small adjustment, e.g., changing only the font size. In other words, the default style is still applied if you change sclass.
To replace the default style completely, use setZclass(_global_.String)
instead.
The real CSS class is a concatenation of getZclass()
and getSclass()
.
sclass
- the style classgetSclass()
,
setZclass(_global_.String)
,
setStyle(_global_.String)
public String getZclass()
setZclass(_global_.String)
,
getSclass()
,
getStyle()
public Widget setZclass(String zclass)
getMold()
).
Default: null but an implementation usually provides a default class, such as z-button.
Calling setZclass with a different value will completely replace the default style of a widget.
Once you change it, all default styles are gone.
If you want to perform small adjustments, use setSclass(_global_.String)
instead.
The real CSS class is a concatenation of getZclass()
and
getSclass()
.
zclass
- the style class used to apply the whole widget.getZclass()
,
setSclass(_global_.String)
,
setStyle(_global_.String)
public String getWidth()
getHeight()
public Widget setWidth(String width)
width
- the width. Remember to specify 'px', 'pt' or '%'.
An empty or null value means "auto"public String getHeight()
getWidth()
public Widget setHeight(String height)
height
- the height. Remember to specify 'px', 'pt' or '%'.
An empty or null value means "auto"public Widget setLeft(String left)
left
- the left. Remember to specify 'px', 'pt' or '%'.
An empty or null value means "auto"public Widget setTop(String top)
bottom
, use setStyle(_global_.String)
instead.
For example, setStyle("bottom: 0px");
top
- the top. Remember to specify 'px', 'pt' or '%'.
An empty or null value means "auto"public String getTooltiptext()
public Widget setTooltiptext(String title)
Default implementation of setTooltiptext: update the title attribute of $n(_global_.String)
title
- the tooltip textpublic String getDroppable()
public Widget setDroppable(String droppable)
Default: null
The simplest way to make a component droppable is to set this attribute to "true". To disable it, set this to "false" (or null).
If there are several types of draggable objects and this widget accepts only some of them, you could assign a list of identifiers that this widget accepts, separated by comma.
For example, if this component accepts dg1 and dg2, then assign "dg1, dg2" to this attribute.
droppable
- "false", null or "" to denote not-droppable; "true" for accepting any draggable types; a list of identifiers, separated by comma for identifiers of draggables this widget accept (to be dropped in).public void setVflex(String flex)
The parameter flex is a number in String type indicating how this widget's parent container distributes remaining empty space among its children widget vertically. Flexible widget grow and shrink to fit their given space. Flexible widget with larger flex values will be made larger than widget with lower flex values, at the ratio determined by all flexible widgets. The actual flex value is not relevant unless there are other flexible widget within the same parent container. Once the default sizes of widget in a parent container are calculated, the remaining space in the parent container is divided among the flexible widgets, according to their flex ratios.
Specify a flex value of negative value, 0, or "false" has the same effect as leaving the flex attribute out entirely. Specify a flex value of "true" has the same effect as a flex value of 1.
Special flex hint, "min", indicates that the minimum space shall be given to this flexible widget to enclose all of its children widgets. That is, the flexible widget grow and shrink to fit its children widgets.
flex
- the vertical flex hint.setHflex(_global_.String)
,
getVflex()
public String getVflex()
setVflex(_global_.String)
public String getHflex()
setHflex(_global_.String)
public void setHflex(String flex)
The parameter flex is a number in String type indicating how this widget's parent container distributes remaining empty space among its children widget horizontally. Flexible widget grow and shrink to fit their given space. Flexible widget with larger flex values will be made larger than widget with lower flex values, at the ratio determined by all flexible widgets. The actual flex value is not relevant unless there are other flexible widget within the same parent container. Once the default sizes of widget in a parent container are calculated, the remaining space in the parent container is divided among the flexible widgets, according to their flex ratios.
Specify a flex value of negative value, 0, or "false" has the same effect as leaving this flex attribute out entirely. Specify a flex value of "true" has the same effect as a flex value of 1.
Special flex hint, "min", indicates that the minimum space shall be given to this flexible widget to enclose all of its children widgets. That is, the flexible widget grow and shrink to fit its children widgets.
flex
- the horizontal flex hint.setVflex(_global_.String)
,
getHflex()
public void setRenderdefer(int ms)
Default: -1 (don't wait).
This method is useful if you have a sophisticated page that takes
long to render at a slow client. You can specify a non-negative value
as the render-defer delay such that the other part of the UI can appear
earlier. The styling of the render-deferred widget is controlled by
a CSS class called z-render-defer
.
Notice that it has no effect if the component has been rendered at the client.
ms
- time to wait in milliseconds before rendering.
Notice: 0 also implies deferring the rendering (just right after
all others are rendered).public int getRenderdefer()
Default: -1 (don't wait).
public void setAction(String action)
Default: null (no CSA at all)
The format:
action1: action-effect1; action2: action-effect2
Currently, only two actions are show
and hide
.
They are called when the widget is becoming visible (show) and invisible (hide).
The action effect (action-effect1
) is the name of a method
defined in zk.eff.Actions,
such as
show: slideDown; hide: slideUp
action
- the client-side actionpublic String getAction()
public void setTabindex(int tabindex)
tabindex
- public int getTabindex()
public void setCssflex(boolean enable)
enable
- css flex or notpublic int getCssflex()
public void $init(Map props)
new zul.wnd.Window({
border: 'normal',
title: 'Hello World',
closable: true
});
props
- the properties to be assigned to this widget.protected void afterAnima_(boolean visible)
jqzk.slideDown(zk.Widget, _global_.Map)
) has finished.
You could override to clean up anything related to animation.
Notice that, if you override, you have to call back this method.visible
- whether the result of the animation will make
the DOM element visiblepublic Widget setDraggable(String draggable)
Default: null
The simplest way to make a widget draggable is to set this property to "true". To disable it, set this to "false" (or null). If there are several types of draggable objects, you could assign an identifier for each type of draggable object. The identifier could be anything but empty and "false".
draggable
- "false", "" or null to denote non-draggable; "true" for draggable with anonymous identifier; others for an identifier of draggable.public String getDraggable()
public Widget $o()
Notice that, if this widget is an ID space owner, this method returns itself.
public Widget $f(String id, boolean global)
id
- the widget's ID (id
)global
- whether to search all ID spaces of this desktop.
If true, it first search its own ID space, and then the other Id spaces in this browser window (might have one or multiple desktops).
If omitted, it won't search all ID spaces.public Widget $f(String id)
id
- the widget's ID (id
)public Map $f()
wgt.$f().main.setTitle("foo");
public String getId()
id
.public Widget setId(String id)
id
- the identifier to assigned to.public Object get(String name)
name
- the name of property.public Widget getChildAt(int j)
Notice this method is not good if there are a lot of children since it iterates all children one by one.
j
- the index of the child widget to return. 0 means the first
child, 1 for the second and so on.getChildIndex()
public int getChildIndex()
Notice that getChildAt(int)
is called against the parent, while
this method called against the child. In other words,
w.parent.getChildAt(w.getChildIndex())
returns w
.
Notice this method is not good if there are a lot of children since it iterates all children one by one.
public Widget setChildren(Array children)
children
- an array of children (Widget
) to addpublic boolean appendChild(Widget child, boolean ignoreDom)
appendChild(zk.Widget)
except the caller
could prevent it from generating DOM element.
It is usually used with rerender(int)
.child
- the child widget to addignoreDom
- whether not to generate DOM elementslastChild
).appendChild(zk.Widget)
,
insertBefore(zk.Widget, zk.Widget)
public boolean appendChild(Widget child)
Desktop
.
In other words, you have to attach child widgets of Desktop
manually (by use of, say, replaceHTML(zk.Object, zk.Desktop, zk.Skipper)
).
insertChildHTML_(zk.Widget, zk.Widget, zk.Desktop)
to insert the DOM content of the child to the DOM tree.
Thus, override insertChildHTML_(zk.Widget, zk.Widget, zk.Desktop)
if you want to insert more than
the DOM content generated by redraw(_global_.Array)
.beforeParentChanged_(zk.Widget)
(which is called by insertBefore(zk.Widget, zk.Widget)
, removeChild(zk.Widget, boolean)
and appendChild(zk.Widget, boolean)
).insertBefore(zk.Widget, zk.Widget)
might invoke this method (if the widget shall be the last child).
To know if it is the case you can check insertingBefore_
.child
- the child widget to addlastChild
).insertBefore(zk.Widget, zk.Widget)
protected boolean shallChildROD_()
Default: return true if child.z_rod or this.z_rod
public boolean insertBefore(Widget child, Widget sibling)
sibling
argument).
insertChildHTML_(zk.Widget, zk.Widget, zk.Desktop)
to insert the DOM content of the child to the DOM tree. Thus, override insertChildHTML_(zk.Widget, zk.Widget, zk.Desktop)
if you want to insert more than the DOM content generated by redraw(_global_.Array)
.beforeParentChanged_(zk.Widget)
(which is called by
insertBefore(zk.Widget, zk.Widget)
, removeChild(zk.Widget, boolean)
and appendChild(zk.Widget, boolean)
).child
- the child widgetsibling
- the sibling widget (the 'insert' point where
the new widget will be placed before). If null or omitted, it is
the same as appendChild(zk.Widget, boolean)
lastChild
).appendChild(zk.Widget)
public boolean removeChild(Widget child, boolean ignoreDom)
removeChild(zk.Widget)
except the caller
could prevent it from removing the DOM element.
Notice that the associated DOM elements and unbind_(zk.Skipper, _global_.Array, boolean)
is called first (i.e., called before beforeParentChanged_(zk.Widget)
,
modifying the widget tree, ID space, and onChildRemoved_(zk.Widget)
).
public boolean removeChild(Widget child)
public void detach()
removeChild(zk.Widget, boolean)
public void clear()
public void replaceWidget(Widget newwgt, Skipper skipper)
Notice that replaceHTML(zk.Object, zk.Desktop, zk.Skipper)
is used to replace a DOM element
that usually doesn't not belong to any widget.
And, replaceWidget(zk.Widget, zk.Skipper)
is used to replace the widget, and
it maintains both the widget tree and the DOM tree.
newwgt
- the new widget that will replace this widget.skipper
- [optional] the skipper used to skip a portion of DOM nodes.replaceHTML(zk.Object, zk.Desktop, zk.Skipper)
protected void replaceCavedChildren_(String subId, Array wgts, String tagBeg, String tagEnd)
subId
(this.$n(subId)).
Note: it assumes this.$n(subId) exists.
subId
- the ID of the cave that contains the child widgets
to replace with.wgts
- an array of widgets that will become children of this widgettagBeg
- the beginning of HTML tag, such as &tl;tbody>.
Ignored if null.tagEnd
- the ending of HTML tag, such as </tbody>
Ignored if null.zAu.createWidgets(_global_.Array, _global_.Function, _global_.Function)
protected void beforeParentChanged_(Widget newparent)
newparent
- the new parent (null if it is removed)
The previous parent can be found by parent
.onChildAdded_(zk.Widget)
,
onChildRemoved_(zk.Widget)
,
afterParentChanged_(zk.Widget)
protected void afterParentChanged_(Widget oldparent)
oldparent
- the previous parent (null if it was not attached)
The current parent can be found by parent
.beforeParentChanged_(zk.Widget)
public boolean isRealVisible(Map opts)
opts
- [optional] the options. Allowed values:
isVisible(boolean)
dom
is also specified.isVisible(boolean)
public boolean isRealVisible()
isVisible(boolean)
public boolean isVisible(boolean strict)
strict
- whether to check the visibility of the associated
DOM element. If true, this widget and the associated DOM element
must be both visible.isRealVisible(_global_.Map)
,
jqzk.isVisible(boolean)
,
setVisible(boolean)
public boolean isVisible()
isRealVisible(_global_.Map)
,
jqzk.isVisible(boolean)
public Widget setVisible(boolean visible)
onChildVisible_(zk.Widget)
, so you
can override onChildVisible_(zk.Widget)
to change the related DOM element.
For example, updating the additional enclosing tags (such as zul.box.Box). setDomVisible_(_global_.DOMElement, boolean, _global_.Map)
to change the visibility of a child DOM element, so override it if necessary.visible
- whether to be visiblepublic void zsync(Map opts)
It is useful to sync the layout, such as shadow, mask and error message, that is tightly associated with a widget.
opts
- the options, or undefined if none of them specified.
Allowed values:public Widget show()
setVisible(true)
public Widget hide()
setVisible(false)
protected void setDomVisible_(DOMElement n, boolean visible, Map opts)
setVisible(boolean)
to really change the visibility
of the associated DOM elements.
Default: change n.style.display directly.
n
- the element (never null)visible
- whether to make it visibleopts
- [optional] the options.
If omitted, {display:true}
is assumed. Allowed value:
protected void onChildAdded_(Widget child)
Notice: when overriding this method, onChildReplaced_(zk.Widget, zk.Widget)
is usually required to override, too.
child
- the child being addedbeforeParentChanged_(zk.Widget)
,
onChildRemoved_(zk.Widget)
protected void onChildRemoved_(Widget child)
Notice: when overriding this method, onChildReplaced_(zk.Widget, zk.Widget)
child
- the child being removedbeforeParentChanged_(zk.Widget)
,
onChildAdded_(zk.Widget)
protected void onChildReplaced_(Widget oldc, Widget newc)
onChildAdded_(zk.Widget)
and onChildRemoved_(zk.Widget)
, this
method is called only if AuCmd1.outer(zk.Widget, _global_.String)
.
And if this method is called, neither onChildAdded_(zk.Widget)
nor onChildRemoved_(zk.Widget)
will be called.
Default: invoke onChildRemoved_(zk.Widget)
and then
onChildAdded_(zk.Widget)
.
Furthermore, it sets this.childReplacing_ to true before invoking
onChildRemoved_(zk.Widget)
and onChildAdded_(zk.Widget)
, so we can optimize
the code (such as rerender only once) by checking its value.
oldc
- the old child (being removed). Note: it might be null.newc
- the new child (being added). Note: it might be null.protected void onChildVisible_(Widget child)
setVisible(boolean)
was called).
Notice that this method is called after the _visible property and the associated DOM element(s) have been changed.
To know if it is becoming visible, you can check isVisible(boolean)
(such as this._visible).
child
- the child whose visiblity is changedprotected void onChildRenderDefer_(Widget child)
child
- the child being rendereddeferRedraw_(_global_.Array)
public int setTopmost()
If this widget is not floating, this method will look for its ancestors for the first ancestor who is floating. In other words, this method makes the floating containing this widget as topmost.
To make a widget floating, use setFloating_(boolean, _global_.Map)
.
This method has no effect if it is not bound to the DOM tree, or none of the widget and its ancestors is floating.
Notice that it does not fire onFloatUp so it is caller's job if it is necessary to close other popups.
setFloating_(boolean, _global_.Map)
protected void setFloatZIndex_(DOMElement node, int zi)
setTopmost()
to set the z-index,
and called only if setFloating_(boolean, _global_.Map)
is ever called.node
- the element whose z-index needs to be set.
It is the value specified in opts.node
when setFloating_(boolean, _global_.Map)
is called. If not specified, it is the same as $n(_global_.String)
.zi
- the z-index to setsetFloating_(boolean, _global_.Map)
protected void getFloatZIndex_(DOMElement node)
setTopmost()
to decide the topmost z-index,
and called only if setFloating_(boolean, _global_.Map)
is ever called.node
- the element whose z-index needs to be set.
It is the value specified in opts.node
when setFloating_(boolean, _global_.Map)
is called. If not specified, it is the same as $n(_global_.String)
.setFloating_(boolean, _global_.Map)
public Widget getTopWidget()
isFloating_()
protected boolean isFloating_()
We say a widget is floating if the widget floats on top of others, rather than embed inside the parent. For example, an overlapped window is floating, while an embedded window is not.
setFloating_(boolean, _global_.Map)
protected Widget setFloating_(boolean floating, Map opts)
Notice that it doesn't change the DOM tree. It is caller's job.
In the other words, the caller have to adjust the style by assigning
position
with absolute
or relative
.
floating
- whether to make it floatingopts
- [optional] The options. Allowed options:
$n(_global_.String)
is assumed.isFloating_()
public int getZIndex()
public Widget setZIndex(int zIndex, Map opts)
zIndex
- the Z index to assign toopts
- if opts.fire is specified the onZIndex event will be triggered. If opts.floatZIndex is false, represent it is not from setFloatZIndex, so the userZIndex may be true.public int getScrollTop()
0 is always returned if this widget is not bound to a DOM element yet.
public int getScrollLeft()
0 is always returned if this widget is not bound to a DOM element yet.
public Widget setScrollTop(int the)
This method does nothing if this widget is not bound to a DOM element yet.
the
- scroll top.public Widget setScrollLeft(int the)
This method does nothing if this widget is not bound to a DOM element yet.
the
- scroll top.public Widget scrollIntoView()
Default: invoke zk(this).scrollIntoView();
jqzk.scrollIntoView(_global_.DOMElement)
public void redraw(Array out)
out.push('<div', this.domAttrs_(), '>'); for (var w = this.firstChild; w; w = w.nextSibling) w.redraw(out); out.push('</div>');
Default: it retrieves the redraw function associated with the mold (
getMold()
) and then invoke it. The redraw function must have the same signature as this method.
out
- an array to output HTML fragments.
Technically it can be anything that has the method called push
protected void deferRedraw_(Array out)
setRenderdefer(int)
).
This method is called automatically by redraw(_global_.Array)
,
so you only need to use it if you override redraw(_global_.Array)
.
A typical usage is as follows.
redraw: function (out) {
if (!this.deferRedraw_(out)) {
out.push(...); //redraw
}
}
out
- an array to output the HTML fragments.protected void deferRedrawHTML_(Array out)
By default, the Div tag is assumed.
out
- an array to output the HTML fragments.public void forcerender()
setRenderdefer(int)
with a non-negative value. The other example is some widget might be
optimized for the performance by not rendering some or the whole part
of the widget. If the rendering is deferred, the corresponding DOM elements
($n(_global_.String)
) are not available. If it is important to you, you can
force it to be rendered.
Notice that this method only forces this widget to render. It doesn't
force any of its children. If you want, you have invoke forcerender()
one-by-one
The derived class shall override this method, if it implements
the render deferring (other than setRenderdefer(int)
).
protected void updateDomClass_()
Default: it changes the class of $n(_global_.String)
.
$n(_global_.String)
.updateDomStyle_()
protected void updateDomStyle_()
Default: it changes the CSS style of $n(_global_.String)
.
$n(_global_.String)
.public DOMElement getTextNode()
Default: return null (no text node).
For example, updateDomStyle_()
will change the style
of the text node, if any, to make sure the text is displayed correctly.
See also ZK Client-side Reference: Text Styles and Inner Tags.
domTextStyleAttr_()
,
updateDomStyle_()
protected String domStyle_(Map no)
Default: a concatenation of style, width, visible and so on.
no
- [options] the style to exclude (i.e., to turn off).
If omitted, it means none (i.e., all included). For example, you don't
want width to generate, call domStyle_({width:1})
.
Notice, though a bit counter-intuition, specify 1 (or true) to denote exclusion.
Allowed value (subclass might support more options):getStyle()
getWidth()
getHeight()
getLeft()
getTop()
getZIndex()
domClass_(_global_.Map)
,
domAttrs_(_global_.Map)
protected String domClass_(Map no)
Default: a concatenation of getZclass()
and getSclass()
.
no
- [options] the style class to exclude (i.e., to turn off).
If omitted, it means none (i.e., all included). For example, you don't
want sclass to generate, call domClass_({sclass:1})
.
Notice, though a bit counter-intuition, specify 1 (or true) to denote exclusion.
Allowed value (subclass might support more options):getSclass()
getZclass()
z-button foo
domStyle_(_global_.Map)
,
domAttrs_(_global_.Map)
protected String domAttrs_(Map no)
redraw(_global_.Array)
):
function () { return '<div' + this.domAttrs_() + '></div>'; }
Default: it generates id, style, class, and tooltiptext. Notice that it invokes
domClass_(_global_.Map)
anddomStyle_(_global_.Map)
, unless they are disabled by theno
argument.
no
- [options] the attributes to exclude (i.e., to turn off).
If omitted, it means none (i.e., all included). For example, you don't
want the style class to generate, call domAttrs_({domClass:1})
.
Notice, though a bit counter-intuition, specify 1 (or true) to denote exclusion.
Allowed value (subclass might support more options):domClass_(_global_.Map)
domStyle_(_global_.Map)
getTooltiptext()
return the HTML attributes, such as id="z_u7_3" class="z-button"
protected String domTooltiptext_()
Default: return getTooltiptext()
.
Deriving class might override this method if the parent widget is not associated with any DOM element, such as treerow's parent: treeitem.
protected String domTextStyleAttr_()
It is usually used with getTextNode()
to
ZK Client-side Reference: Text Styles and Inner Tags.
getTextNode()
public Widget replaceHTML(Object n, Desktop desktop, Skipper skipper)
jq(n).replaceWith(wgt, desktop, skipper)
.
The DOM element to be replaced can be $n(_global_.String)
or any independent DOM element. For example, you can replace a DIV element (and all its descendants) with this widget (and its descendants).
This method is usually used to replace a DOM element with a root widget (though, with care, it is OK for non-root widgets). Non-root widgets usually use appendChild(zk.Widget, boolean)
and insertBefore(zk.Widget, zk.Widget)
to attach to the DOM tree[1]
If the DOM element doesn't exist, you can use jq.before(java.lang.Object, zk.Desktop)
or jq.after(java.lang.Object, zk.Desktop)
instead.
Notice that, both replaceHTML(zk.Object, zk.Desktop, zk.Skipper)
fires the beforeSize and onSize watch events
(refer to zWatch
).
If skipper is null. It implies the caller has to fire these two events if it specifies a skipper
(that is how rerender(int)
is implemented).
replaceChildHTML_(zk.Widget, _global_.DOMElement, zk.Desktop, zk.Skipper)
to really replace the DOM element.
Thus, override replaceChildHTML_(zk.Widget, _global_.DOMElement, zk.Desktop, zk.Skipper)
if you want to do something special for particular child widgets.n
- the DOM element (DOMElement
) or anything
$(zk.Object, _global_.Map)
allowed.desktop
- [optional] the desktop that this widget shall belong to.
If omitted, it is retrieve from the current desktop.
If null, it is decided automatically ( such as the current value of desktop
or the first desktop)skipper
- [optional] it is used only if it is called by rerender(int)
replaceWidget(zk.Widget, zk.Skipper)
,
jq.replaceWith(zk.Widget, zk.Desktop, zk.Skipper)
protected void getOldWidget_(DOMElement n)
replaceHTML(zk.Object, zk.Desktop, zk.Skipper)
and replaceChildHTML_(zk.Widget, _global_.DOMElement, zk.Desktop, zk.Skipper)
to retrieve
the widget associated with the note.
It is similar to $(zk.Object, _global_.Map)
but it gives the widget a chance to
handle extreme cases. For example, Treeitem doesn't associate a DOM element
(or you can say Treeitem and Treerow shares the same DOM element), so
zk.Widget.$(n)
will return Treerow, not Treeitem.
If it is the case, you can override it to make replaceHTML(zk.Object, zk.Desktop, zk.Skipper)
works correctly.
n
- the DOM element to match the widget.protected String redrawHTML_(Skipper skipper, boolean trim)
skipper
- the skipper. Ignored if nulltrim
- whether to trim the HTML content before replacingpublic Widget rerender(int timeout)
Notice that, to have the best performance, we use the single timer to handle all pending rerenders for all widgets. In other words, if the previous timer is not expired (and called), the second call will reset the expiration time to the value given in the second call.
timeout
- the number milliseconds (non-negative) to wait
before rerender. If negative, it means rerender shall take place
immediately. If not specified, 0 is assumed (since ZK 6).public Widget rerender(Skipper skipper)
redraw(_global_.Array)
)
and then replace the DOM elements with the new generated HTML code snippet.
It is equivalent to replaceHTML(this.node, null, skipper).
It is usually used to implement a setter of this widget.
For example, if a setter (such as setBorder
) has to
modify the visual appearance, it can update the DOM tree directly,
or it can call this method to re-render all DOM elements associated
with is widget and its descendants.
It is convenient to synchronize the widget's state with the DOM tree with this method. However, it shall be avoided if the HTML code snippet is complex (otherwise, the performance won't be good).
If re-rendering is required, you can improve the performance
by passing an instance of Skipper
that is used to
re-render some or all descendant widgets of this widget.
skipper
- [optional] skip some portion of this widget
to speed up the re-rendering.
If not specified, rerender(0) is assumed (since ZK 6).protected Widget rerenderLater_()
protected void replaceChildHTML_(Widget child, DOMElement n, Desktop dt, Skipper skipper)
replaceHTML(zk.Object, zk.Desktop, zk.Skipper)
to give the parent a chance to
do something special for particular child widgets.child
- the child widget whose DOM content is used to replace the DOM treen
- the DOM element to be replaceddt
- [optional the desktop that this widget shall belong to.
If null, it is decided automatically ( such as the current value of desktop
or the first desktop)skipper
- it is used only if it is called by rerender(int)
protected void insertChildHTML_(Widget child, Widget before, Desktop desktop)
insertBefore(zk.Widget, zk.Widget)
and appendChild(zk.Widget, boolean)
to handle the DOM tree.
Deriving classes might override this method to modify the HTML content, such as enclosing with TD.
Notice that when inserting the child (without the before argument), this method will call getCaveNode()
to find the location to place the DOM element of the child. More precisely, the node returned by getCaveNode()
is the parent DOM element of the child. The default implementation of getCaveNode()
is to look for a sub-node named uuid$cave. In other words, it tried to place the child inside the so-called cave sub-node, if any.
Otherwise, $n(_global_.String)
is assumed.
child
- the child widget to insertbefore
- the child widget as the reference to insert the new child before. If null, the HTML content will be appended as the last child.
The implementation can use before.getFirstNode_() (getFirstNode_()
) to retrieve the DOM elementdesktop
- getCaveNode()
public DOMElement getCaveNode()
insertChildHTML_(zk.Widget, zk.Widget, zk.Desktop)
to find the location to place the DOM element of the child.
More precisely, the node returned by getCaveNode()
is the parent DOM element of the child's DOM element.
Default: this.$n('cave') || this.$n()
You can override it to return whatever DOM element you want.
insertChildHTML_(zk.Widget, zk.Widget, zk.Desktop)
protected DOMElement getFirstNode_()
This method is designed to be used with insertChildHTML_(zk.Widget, zk.Widget, zk.Desktop)
for retrieving the DOM element of the before
widget.
protected void removeChildHTML_(Widget child, boolean ignoreDom)
removeChild(zk.Widget, boolean)
to remove the DOM content.
The default implementation of this method will invoke removeHTML_(_global_.Array)
if the ignoreDom argument is false or not specified.
Overrides this method or removeHTML_(_global_.Array)
if you have to
remove DOM elements other than child's node (and the descendants).
child
- the child widget to removeignoreDom
- whether to remove the DOM elementprotected void removeHTML_(Array n)
The default implementation simply removes the DOM element passed in.
Overrides this method if you have to remove the related DOM elements.
n
- an array of DOMElement
to remove.
If this widget is associated with a DOM element ($n(_global_.String)
returns non-null),
n is a single element array.
If this widget is not associated with any DOM element, an array of
child widget's DOM elements are returned.public DOMElement $n(String subId)
uuid
, -, and subId. For example,
var cave = wgt.$n('cave'); //the same as jq('#' + wgt.uuid + '-' + 'cave')[0]
Like $n()
, this method caches the result so the performance is much better
than invoking jq() directly.subId
- the sub ID of the child element$n()
public DOMElement $n()
Timer
).
Notice that desktop
is always non-null if it is bound to the DOM tree.
In additions, this method is much faster than invoking jq() (see jq
,
since it caches the result (and clean up at the unbind_(zk.Skipper, _global_.Array, boolean)
).
var n = wgt.$n();
$n(String)
public Service $service()
public boolean isRealElement()
public String $s()
setZclass(String)
).
var subzcls = wgt.$s('hover'); // z-xxx-hover will be return
getZclass()
public void clearCache()
$n(_global_.String)
).public Page getPage()
public boolean isBinding()
bind(zk.Desktop, zk.Skipper, boolean)
is called
against this widget or any of its ancestors.protected void rerenderNow_(Skipper skipper)
skipper
- [optional] used if rerender(int)
is called with a non-null skipper.public void bindMissingAncestors(Desktop desktop, Skipper skipper)
desktop
- [optional] the desktop the DOM element belongs to.
If not specified, ZK will decide it automatically.skipper
- [optional] used if rerender(int)
is called with a non-null skipper.public Widget bind(Desktop desktop, Skipper skipper, boolean bindSelfOnly)
Notice that you rarely need to invoke this method, since
it is called automatically (such as replaceHTML(zk.Object, zk.Desktop, zk.Skipper)
and appendChild(zk.Widget, boolean)
).
Notice that you rarely need to override this method, either.
Rather, override bind_(zk.Desktop, zk.Skipper, _global_.Array, boolean)
instead.
desktop
- [optional] the desktop the DOM element belongs to.
If not specified, ZK will decide it automatically.skipper
- [optional] used if rerender(int)
is called with a non-null skipper.bindSelfOnly
- [optional] set to true if one doesn't want to recursively bind descendents.bind_(zk.Desktop, zk.Skipper, _global_.Array, boolean)
,
unbind(zk.Skipper, boolean)
public Widget unbind(Skipper skipper, boolean keepRod)
Notice that you rarely need to invoke this method, since
it is called automatically (such as replaceHTML(zk.Object, zk.Desktop, zk.Skipper)
).
Notice that you rarely need to override this method, either.
Rather, override unbind_(zk.Skipper, _global_.Array, boolean)
instead.
skipper
- [optional] used if rerender(int)
is called with a non-null skipper.keepRod
- [optional] used if the ROD flag needs to be kept.unbind_(zk.Skipper, _global_.Array, boolean)
,
bind(zk.Desktop, zk.Skipper, boolean)
protected void bind_(Desktop dt, Skipper skipper, Array after, boolean bindSelfOnly)
redraw(_global_.Array)
)
(for example, by replaceHTML(zk.Object, zk.Desktop, zk.Skipper)
).
Note: don't invoke this method directly. Rather, invoke bind(zk.Desktop, zk.Skipper, boolean)
instead.
wgt.bind();
Subclass overrides this method to initialize the DOM element(s), such as adding a DOM listener. Refer to Widget and DOM Events and domListen_(_global_.DOMElement, _global_.String, zk.Object, _global_.String)
for more information.
dt
- [optional] the desktop the DOM element belongs to.
If not specified, ZK will decide it automatically.skipper
- [optional] used if rerender(int)
is called with a non-null skipper.after
- an array of function (Function
) that will be invoked after bind_(zk.Desktop, zk.Skipper, _global_.Array, boolean)
has been called. For example,
bind_: function (desktop, skipper, after) {
this.$supers('bind_', arguments);
var self = this;
after.push(function () {
self._doAfterBind(something);
...
});
}
bindSelfOnly
- [optional] set to true if one doesn't want to recursively bind descendents.bind(zk.Desktop, zk.Skipper, boolean)
,
unbind_(zk.Skipper, _global_.Array, boolean)
protected void bindChildren_(Desktop dt, Skipper skipper, Array after)
bind_(zk.Desktop, zk.Skipper, _global_.Array, boolean)
to invoke child's bind_(zk.Desktop, zk.Skipper, _global_.Array, boolean)
one-by-one.dt
- [optional] the desktop the DOM element belongs to.
If not specified, ZK will decide it automatically.skipper
- [optional] used if rerender(int)
is called with a non-null skipper.after
- an array of function (Function
) that will be invoked after bind_(zk.Desktop, zk.Skipper, _global_.Array, boolean)
has been called. For example,protected void unbind_(Skipper skipper, Array after, boolean keepRod)
removeChild(zk.Widget, boolean)
.
Note: don't invoke this method directly. Rather, invoke unbind(zk.Skipper, boolean)
instead.
Note: after invoking this.$supers('unbind_', arguments)
,
the association with DOM elements are lost. Thus it is better to invoke
it as the last statement.
Notice that removeChild(zk.Widget, boolean)
removes DOM elements first, so
unbind_(zk.Skipper, _global_.Array, boolean)
is called before beforeParentChanged_(zk.Widget)
and
the modification of the widget tree. It means it is safe to access
parent
and other information here
skipper
- [optional] used if rerender(int)
is called with a non-null skipperafter
- an array of function (Function
)that will be invoked after unbind_(zk.Skipper, _global_.Array, boolean)
has been called. For example,
unbind_: function (skipper, after) {
var self = this;
after.push(function () {
self._doAfterUnbind(something);
...
}
this.$supers('unbind_', arguments);
}
keepRod
- [optional] used if the ROD flag needs to be kept.bind_(zk.Desktop, zk.Skipper, _global_.Array, boolean)
,
unbind(zk.Skipper, boolean)
protected void unbindChildren_(Skipper skipper, Array after, boolean keepRod)
unbind_(zk.Skipper, _global_.Array, boolean)
to invoke child's unbind_(zk.Skipper, _global_.Array, boolean)
one-by-one.skipper
- [optional] used if rerender(int)
is called with a non-null skipperafter
- an array of function (Function
)that will be invoked after unbind_(zk.Skipper, _global_.Array, boolean)
has been called. For example,keepRod
- [optional] used if the ROD flag needs to be kept.protected void extraBind_(String uuid, boolean add)
Notice that uuid
is automatically associated (aka., bound) to this widget.
Thus, you rarely need to invoke this method unless you want to associate with other identifiers.
For example, ZK Google Maps uses this method since it has to bind the anchors manually.
uuid
- the UUID to assign to the widgtetadd
- whether to bind. Specify true if you want to bind;
false if you want to unbind.protected void initDrag_()
getDraggable()
is set (and bound).
You rarely need to override this method, unless you want to handle drag-and-drop differently.
Default: use Draggable
to implement drag-and-drop,
and the handle to drag is the element returned by getDragNode()
cleanDrag_()
protected void cleanDrag_()
getDraggable()
is cleaned (or unbound).
You rarely need to override this method, unless you want to handle drag-and-drop differently.
cleanDrag_()
public DOMElement getDragNode()
Default, it returns $n(_global_.String)
, i.e., the user can drag the widget anywhere.
ignoreDrag_(zk.Draggable)
protected Map getDragOptions_(Map map)
Draggable
.
Default, it does nothing but returns the map
parameter,
i.e., the default options.
Though rarely used, you can override any option passed to
Draggable
, such as the start effect, ghosting and so on.
map
- the default implementationprotected boolean ignoreDrag_(Draggable pt)
Default: it always returns false.
If the location that an user can drag is static, override getDragNode()
,
which is easier to implement.
pt
- protected Widget getDrop_(Widget dragged)
Default: it check if the values of droppable and draggable match. It will check the parent (parent
), parent's parent, and so on until matched, or none of them are matched.
Notice that the widget to test if droppable might be the same as the widget being dragged (i.e., this == dragged). By default, we consider them as non-matched.
dragged
- - the widget being dragged (never null).protected void dropEffect_(boolean over)
Default, it adds the CSS class named 'z-drag-over' if over is true, and remove it if over is false.
over
- whether the user is dragging over (or out, if false)protected String getDragMessage_()
cloneDrag_(zk.Draggable, _global_.Offset)
.
Default, it return the inner text if if $n(_global_.String)
returns a TR, TD, or TH element. Otherwise, it returns null and cloneDrag_(zk.Draggable, _global_.Offset)
will be called to create a DOM element to indicate dragging.
Notice that the text would be encoded for XSS issue since 8.0.4.2. It should be considered when overriding.
protected void onDrop_(Draggable drag, Event evt)
Default, it fires the onDrop event (with fire(_global_.String, zk.Object, _global_.Map, int)
).
The subclass can override this method to pass more options such as the coordination where a widget is dropped.
drag
- the draggable controllerevt
- the event causes the dropprotected DOMElement cloneDrag_(Draggable drag, Offset ofs)
This method is called if getDragMessage_()
returns null.
If getDragMessage_()
returns a string (empty or not),
a small popup containing the message is created to represent the widget being dragged.
You rarely need to override this method, unless you want a different visual effect.
drag
- the draggable controllerofs
- the offset of the returned element (left/top)uncloneDrag_(zk.Draggable)
protected void uncloneDrag_(Draggable drag)
cloneDrag_(zk.Draggable, _global_.Offset)
.drag
- the draggable controllerpublic void onAfterSize()
public boolean focus(int timeout)
canActivate(_global_.Map)
first.
Notice: don't override this method. Rather, override focus_(int)
,
which this method depends on.
timeout
- how many milliseconds before changing the focus. If not specified or negative, the focus is changed immediately,protected boolean focus_(int timeout)
focus(int)
to set the focus.
Default: call child widget's focus until it returns true, or no child at all.
jqzk.focus(int)
.
focus_: function (timeout) {
zk(this.$n('foo').focus(timeout);
return true;
}
timeout
- how many milliseconds before changing the focus. If not specified or negative, the focus is changed immediately,public boolean canActivate(Map opts)
Default: return false if it is not a descendant of
zk.currentModal
.
opts
- [optional] the options. Allowed values:
zk.currentModal
.
In additions, if specified, it will ignore zk
, which is set
if AuCmd0.showBusy(_global_.String)
is called.
This flag is usually set by focus(int)
, and not set
if it is caused by user's activity, such as clicking.public Widget smartUpdate(String name, Object value, int timeout)
It is actually fired an AU request named setAttr
, and
it is handled by the updateByClient
method in org.zkoss.zk.ui.AbstractComponent
(at the server).
By default, it is controlled by a component attribute called org.zkoss.zk.ui.updateByClient
.
And, it is default to false.
Thus, the component developer has to override updateByClient
at
the server (in Java) and then update it rather than calling back superclass.
For example,
protected void updateByClient(String name, Object value) {
if ("disabled".equals(name))
setDisabled(value instanceof Boolean && ((Boolean)value).booleanValue());
else
super.updateByClient(name, value);
}
name
- the property namevalue
- the property valuetimeout
- the delay before sending out the AU request. It is optional. If omitted, -1 is assumed (i.e., it will be sent with next non-deferrable request).zAu.send(zk.Event, int)
public Event fireX(Event evt, int timeout)
evt
- the event to firetimeout
- the delay before sending the non-deferrable AU request (if necessary).
If not specified or negative, it is decided automatically.
It is ignored if no non-deferrable listener is registered at the server.fire(_global_.String, zk.Object, _global_.Map, int)
,
listen(_global_.Map, int)
protected void beforeSendAU_(Widget wgt, Event evt)
sendAU_(zk.Event, int)
.
Default: this method will stop the event propagation
and prevent the browser's default handling
(by calling Event.stop(_global_.Map)
),
if the event is onClick, onRightClick or onDoubleClick.
Notice that sendAU_(zk.Event, int)
is called against the widget sending the AU request
to the server, while beforeSendAU_(zk.Widget, zk.Event)
is called against the event's
target (evt.target).
Notice that since this method will stop the event propagation for onClick,
onRightClick and onDoubleClick, it means the event propagation is stopped
if the server registers a listener. However, it doesn't stop if
only a client listener is registered (and, in this case, Event.stop(_global_.Map)
must be called explicitly if you want to stop).
wgt
- the widget that causes the AU request to be sent.
It will be the target widget when the server receives the event.evt
- the event to be sent back to the server.
Its content will be cloned to the AU request.sendAU_(zk.Event, int)
protected void sendAU_(Event evt, int timeout)
fire(_global_.String, zk.Object, _global_.Map, int)
will send an AU request to the server.
Override Notice: sendAU_(zk.Event, int)
will call evt.target's
beforeSendAU_(zk.Widget, zk.Event)
to give the original target a chance to
process it.
evt
- the event that will be sent to the server.timeout
- the delay before really sending out the AU requestfire(_global_.String, zk.Object, _global_.Map, int)
,
beforeSendAU_(zk.Widget, zk.Event)
,
zAu.sendAhead(zk.Event, int)
protected boolean shallIgnoreClick_(Event the)
doClick_(zk.Event)
doRightClick_(zk.Event)
, or doDoubleClick_(zk.Event)
.
Default: return false.
Deriving class might override this method to return true if it wants to ignore the click on certain DOM elements, such as the open icon of a treerow.
Notice: if true is returned, doClick_(zk.Event)
doRightClick_(zk.Event)
, and doDoubleClick_(zk.Event)
won't be called.
In additions, the popup and context of Widget
won't be
handled, either.
the
- event that causes the click (doClick_(zk.Event)
doRightClick_(zk.Event)
, or doDoubleClick_(zk.Event)
).public Event fire(String evtnm, Object data, Map opts, int timeout)
Event
is created to represent the event.
The event listeners for this event will be called one-by-one unless Event.stop(_global_.Map)
is called.
If the event propagation is not stopped (i.e., Event.stop(_global_.Map)
not called)
and inServer
is true, the event will be converted to an AU request and sent to the server.
Refer to ZK Client-side Reference: AU Requests: Client-side Firing for more information.
evtnm
- the event name, such as onClickdata
- [optional] the data depending on the event (Event
).opts
- [optional] the options. Refer to Event.opts
timeout
- the delay before sending the non-deferrable AU request (if necessary).
If not specified or negative, it is decided automatically.
It is ignored if no non-deferrable listener is registered at the server.fire(_global_.String, zk.Object, _global_.Map, int)
,
listen(_global_.Map, int)
public Widget listen(Map infos, int priority)
wgt.listen({
onClick: wgt,
onOpen: wgt._onOpen,
onMove: [o, o._onMove]
});
As shown above, you can register multiple listeners at the same time, and echo value in infos can be a target, a function, or a two-element array, where the first element is a target and the second the function.
A target can be any object that this will reference to when the event listener is called.
Notice it is not Event.target
. Rather, it is this
when the listener is called.
If the function is not specified, the target must have a method having the same name as the event. For example, if wgt.listen({onChange: target}) was called, then target.onChange(evt) will be called when onChange event is fired (by fire(_global_.String, zk.Object, _global_.Map, int)
). On the other hand, if the target is not specified, the widget is assumed to be the target.
infos
- a map of event listeners.
Each key is the event name, and each value can be the target, the listener function, or a two-element array, where the first element is the target and the second the listener function.
Notice that the target is not Event.target
. Rather, it is this
when the listener is called.priority
- the higher the number, the earlier it is called. If omitted, 0 is assumed.
If a widget needs to register a listener as the default behavior (such as zul.wnd.Window's onClose), -1000 is suggestedunlisten(_global_.Map)
,
fire(_global_.String, zk.Object, _global_.Map, int)
,
fireX(zk.Event, int)
,
setListeners(_global_.Map)
,
setListener(_global_.String, _global_.Function)
public Widget unlisten(Map infos)
wgt.unlisten({
onClick: wgt,
onOpen: wgt._onOpen,
onMove: [o, o._onMove]
});
infos
- a map of event listeners.
Each key is the event name, and each value can be the target, the listener function, or a two-element array, where the first element is the target and the second the listener function.listen(_global_.Map, int)
,
isListen(_global_.String, _global_.Map)
,
fire(_global_.String, zk.Object, _global_.Map, int)
,
fireX(zk.Event, int)
public boolean isListen(String evtnm, Map opts)
evtnm
- the event name, such as onClick.opts
- [optional] the options. If omitted, it checks only if the server registers any non-deferrable listener, and if the client register any listener. Allowed values:
public void setListeners(Map infos)
listen(_global_.Map, int)
, except
infs
argumentFunction
automatically.This method is mainly designed to be called by the application running at the server.
Example:
wgt.setListeners({
onChange: function (event) {this.doSomething();},
onFocus: 'this.doMore();',
onBlur: null //unlisten
});
infos
- a map of event listeners.
Each key is the event name, and each value is a string, a function or null.
If the value is null, it means unlisten.
If the value is a string, it will be converted to a Function
.
Notice that the target is not Event.target
. Rather, it is this
when the listener is called.public void setListener(String evt, Function fn)
listen(_global_.Map, int)
.
Use it only if you want to unlisten the listener registered at the
server (by use of the client namespace).
It is based listen(_global_.Map, int)
, but, unlike listen(_global_.Map, int)
, the second
invocation for the same event will unlisten the previous one automatically.
In additions, if fn is null, it unlistens the previous invocation.
evt
- the event namefn
- the listener function.
If null, it means unlisten.setListeners(_global_.Map)
,
listen(_global_.Map, int)
public void setListener(Array inf)
listen(_global_.Map, int)
.
It is based listen(_global_.Map, int)
, but, unlike listen(_global_.Map, int)
, the second
invocation for the same event will unlisten the previous one automatically.
In additions, if the function (specified in the second element of inf) is null, it unlistens the previous invocation.
inf
- a two-element array. The first element is the event name,
while the second is the listener functionsetListeners(_global_.Map)
protected void doSelect_(Event evt)
doClick_(zk.Event)
and doRightClick_(zk.Event)
.
Default: does nothing but invokes the parent's doSelect_(zk.Event)
.
Notice that it does not fire any event.
Deriving class that supports selection (such as ItemWidget
)
shall override this to handle the selection.
Technically, the selection can be handled in doClick_(zk.Event)
.
However, it is better to handle here since this method is invoked first
such that the widget will be selected before one of its descendant widget
handles doClick_(zk.Event)
.
Notice that calling Event.stop(_global_.Map)
will stop the invocation of
parent's doSelect_(zk.Event)
and doClick_(zk.Event)
/doRightClick_(zk.Event)
.
If you just don't want to call parent's doSelect_(zk.Event)
, simply
not to invoke super's doSelect_.
evt
- the widget event.
The original DOM event and target can be retrieved by Event.domEvent
and Event.domTarget
doClick_(zk.Event)
,
doRightClick_(zk.Event)
protected void doTooltipOver_()
doMouseOver_(zk.Event)
.
Default: does nothing but invokes the parent's doTooltipOver_()
.
Notice that it does not fire any event.
Notice that calling Event.stop(_global_.Map)
will stop the invocation of
parent's doTooltipOver_()
and doMouseOver_(zk.Event)
.
If you just don't want to call parent's doMouseOver_(zk.Event)
, simply
not to invoke super's doMouseOver_.
doTooltipOut_()
protected void doTooltipOut_()
doMouseOut_(zk.Event)
.
Default: does nothing but invokes the parent's doTooltipOut_()
.
Notice that it does not fire any event.
Notice that calling Event.stop(_global_.Map)
will stop the invocation of
parent's doTooltipOut_()
and doMouseOut_(zk.Event)
.
If you just don't want to call parent's doMouseOut_(zk.Event)
, simply
not to invoke super's doMouseOut_.
doTooltipOver_()
protected void doClick_(Event evt)
Default: fire the widget event (fireX(zk.Event, int)
), and call parent's doClick_
if the event propagation is not stopped (Event.stopped
).
It is the so-called event propagation.
If a widget, such as zul.wgt.Button, handles onClick, it is better to override this method and not calling back the superclass.
Note: if shallIgnoreClick_(zk.Event)
returns true, fireX(zk.Event, int)
won't be
called and this method invokes the parent's doClick_(zk.Event)
instead
(unless Event.stopped
is set).
evt
- the widget event.
The original DOM event and target can be retrieved by Event.domEvent
and Event.domTarget
doDoubleClick_(zk.Event)
,
doRightClick_(zk.Event)
,
doSelect_(zk.Event)
protected void doDoubleClick_(Event evt)
Default: fire the widget event (fireX(zk.Event, int)
), and call parent's
doDoubleClick_ if the event propagation is not stopped (Event.stopped
).
It is the so-called event propagation.
Note: if shallIgnoreClick_(zk.Event)
returns true, fireX(zk.Event, int)
won't be
called and this method invokes the parent's doDoubleClick_(zk.Event)
instead
(unless Event.stopped
is set).
evt
- the widget event.
The original DOM event and target can be retrieved by Event.domEvent
and Event.domTarget
doClick_(zk.Event)
,
doRightClick_(zk.Event)
protected void doRightClick_(Event evt)
Default: fire the widget event (fireX(zk.Event, int)
), and call parent's
doRightClick_ if the event propagation is not stopped (Event.stopped
).
It is the so-called event propagation.
Note: if shallIgnoreClick_(zk.Event)
returns true, fireX(zk.Event, int)
won't be
called and this method invokes the parent's doRightClick_(zk.Event)
instead
(unless Event.stopped
is set).
evt
- the widget event.
The original DOM event and target can be retrieved by Event.domEvent
and Event.domTarget
doClick_(zk.Event)
,
doDoubleClick_(zk.Event)
protected void doMouseOver_(Event evt)
Default: fire the widget event (fireX(zk.Event, int)
), and
call parent's doMouseOver_ if the event propagation is not stopped (Event.stopped
).
evt
- the widget event.
The original DOM event and target can be retrieved by Event.domEvent
and Event.domTarget
doMouseMove_(zk.Event)
,
doMouseOver_(zk.Event)
,
doMouseOut_(zk.Event)
,
doMouseDown_(zk.Event)
,
doMouseUp_(zk.Event)
,
doTooltipOver_()
protected void doMouseOut_(Event evt)
Default: fire the widget event (fireX(zk.Event, int)
), and
call parent's doMouseOut_ if the event propagation is not stopped (Event.stopped
).
evt
- the widget event.
The original DOM event and target can be retrieved by Event.domEvent
and Event.domTarget
doMouseMove_(zk.Event)
,
doMouseOver_(zk.Event)
,
doMouseDown_(zk.Event)
,
doMouseUp_(zk.Event)
,
doTooltipOut_()
protected void doMouseDown_(Event evt)
Default: fire the widget event (fireX(zk.Event, int)
), and
call parent's doMouseDown_ if the event propagation is not stopped (Event.stopped
).
evt
- the widget event.
The original DOM event and target can be retrieved by Event.domEvent
and Event.domTarget
doMouseMove_(zk.Event)
,
doMouseOver_(zk.Event)
,
doMouseOut_(zk.Event)
,
doMouseUp_(zk.Event)
,
doClick_(zk.Event)
protected void doMouseUp_(Event evt)
Default: fire the widget event (fireX(zk.Event, int)
), and
call parent's doMouseUp_ if the event propagation is not stopped (Event.stopped
).
It is the so-called event propagation.
evt
- the widget event.
The original DOM event and target can be retrieved by Event.domEvent
and Event.domTarget
doMouseMove_(zk.Event)
,
doMouseOver_(zk.Event)
,
doMouseOut_(zk.Event)
,
doMouseDown_(zk.Event)
,
doClick_(zk.Event)
protected void doMouseMove_(Event evt)
Default: fire the widget event (fireX(zk.Event, int)
), and
call parent's doMouseMove_ if the event propagation is not stopped (Event.stopped
).
It is the so-called event propagation.
evt
- the widget event.
The original DOM event and target can be retrieved by Event.domEvent
and Event.domTarget
doMouseOver_(zk.Event)
,
doMouseOut_(zk.Event)
,
doMouseDown_(zk.Event)
,
doMouseUp_(zk.Event)
protected void doKeyDown_(Event evt)
focus(int)
).
Notice that not every widget can have the focus. A widget doesn't need to listen the keydown DOM event. Rather, it shall override this method if necessary.
Default: fire the widget event (fireX(zk.Event, int)
), and
call parent's doKeyDown_ if the event propagation is not stopped (Event.stopped
).
It is the so-called event propagation.
evt
- the widget event.
The original DOM event and target can be retrieved by Event.domEvent
and Event.domTarget
doKeyUp_(zk.Event)
,
doKeyPress_(zk.Event)
protected void doKeyUp_(Event evt)
focus(int)
).
Notice that not every widget can have the focus. A widget doesn't need to listen the keyup DOM event. Rather, it shall override this method if necessary.
Default: fire the widget event (fireX(zk.Event, int)
), and
call parent's doKeyUp_ if the event propagation is not stopped (Event.stopped
).
It is the so-called event propagation.
evt
- the widget event.
The original DOM event and target can be retrieved by Event.domEvent
and Event.domTarget
doKeyDown_(zk.Event)
,
doKeyPress_(zk.Event)
protected void doKeyPress_(Event evt)
focus(int)
).
Notice that not every widget can have the focus. A widget doesn't need to listen the keypress DOM event. Rather, it shall override this method if necessary.
Default: fire the widget event (fireX(zk.Event, int)
), and
call parent's doKeyPress_ if the event propagation is not stopped (Event.stopped
).
It is the so-called event propagation.
evt
- the widget event.
The original DOM event and target can be retrieved by Event.domEvent
and Event.domTarget
doKeyDown_(zk.Event)
,
doKeyUp_(zk.Event)
protected void doPaste_(Event evt)
focus(int)
).
Notice that not every widget can have the focus. A widget doesn't need to listen the paste DOM event. Rather, it shall override this method if necessary.
Default: fire the widget event (fireX(zk.Event, int)
), and
call parent's doPaste_ if the event propagation is not stopped (Event.stopped
).
It is the so-called event propagation.
evt
- the widget event.
The original DOM event and target can be retrieved by Event.domEvent
and Event.domTarget
doKeyDown_(zk.Event)
,
doKeyUp_(zk.Event)
,
doKeyPress_(zk.Event)
protected void doSwipe_(Event evt)
For example,
var opts = evt.opts, dir = opts.dir;
switch (dir) {
case 'left': doSwipeLeft(); break;
case 'right': doSwipeRight(); break;
case 'up': doSwipeUp(); break;
case 'down': doSwipeDown(); break;
}
To define swipe direction rather than default condition,
var opts = evt.opts, start = opts.start, stop = opts.stop,
dispT = stop.time - start.time,
deltaX = start.coords[0] - stop.coords[0],
deltaY = start.coords[1] - stop.coords[1],
dispX = Math.abs(deltaX),
dispY = Math.abs(deltaY);
//if swipe time is less than 500ms, it is considered as swipe event
if (dispT < 500) {
//if horizontal displacement is larger than 30px and vertical displacement is smaller than 75px, it is considered swipe left/right
if (dispX > 30 && dispY < 75)
//swipe left if deltaX > 0
//if vertical displacement is large than 30px and horizontal displacement is smaller than 75px, it is considered swipe up/down
else if (dispY > 30 && dispX < 75)
//swipe up if deltaY > 0
}
Default: fire the widget event (fireX(zk.Event, int)
), and
call parent's doSwipe_ if the event propagation is not stopped (Event.stopped
).
It is the so-called event propagation.
evt
- the widget event.protected void doFocus_(Event evt)
onFocus
.
Unlike other doXxx_ (such as doClick_(zk.Event)
), a widget needs to listen
the onFocus event explicitly if it might gain and lose the focus.
For example,
var fn = this.$n('focus');
this.domListen_(fn, 'onFocus', 'doFocus_');
this.domListen_(fn, 'onBlur', 'doBlur_');
Of course, you can listen it with jQuery DOM-level utilities, if you pefer to handle it differently.
Default: fire the widget event (fireX(zk.Event, int)
), and
call parent's doFocus_ if the event propagation is not stopped (Event.stopped
).
It is the so-called event propagation.
evt
- the widget event.
The original DOM event and target can be retrieved by Event.domEvent
and Event.domTarget
doBlur_(zk.Event)
protected void doBlur_(Event evt)
onBlur
.
Unlike other doXxx_ (such as doClick_(zk.Event)
), a widget needs to listen
the onBlur event explicitly if it might gain and lose the focus.
For example,
var fn = this.$n('focus');
this.domListen_(fn, 'onFocus', 'doFocus_');
this.domListen_(fn, 'onBlur', 'doBlur_');
Of course, you can listen it with jQuery DOM-level utilities, if you pefer to handle it differently.
Default: fire the widget event (fireX(zk.Event, int)
), and
call parent's doBlur_ if the event propagation is not stopped (Event.stopped
).
It is the so-called event propagation.
evt
- the widget event.
The original DOM event and target can be retrieved by Event.domEvent
and Event.domTarget
doFocus_(zk.Event)
protected void doResizeScroll_()
protected Widget domListen_(DOMElement node, String evtnm, Object fn, String keyword)
bind_: function () {
this.$supers('bind_', arguments);
this.domListen_(this.$n(), "onChange"); //fn is omitted, so _doChange is assumed
this.domListen_(this.$n("foo"), "onSelect", "_doFooSelect"); //specify a particular listener
},
unbind_: function () {
this.domUnlisten_(this.$n(), "onChange"); //unlisten
this.domUnlisten_(this.$n("foo"), "onSelect", "_doFooSelect");
this.$supers('unbind_', arguments);
},
_doChange_: function (evt) { //evt is an instance of zk.Event
//event listener
},
_doFooSelect: function (evt) {
}
See also ZK Client-side Reference: Notifications
$weave
).
Furthermore, this method does nothing if the widget is in the design mode.
Thus, if you want to listen a DOM event (Event
), you have
to use jQuery directly.node
- a node of this widget.
It is usually retrieved by $n(_global_.String)
.evtnm
- the event name to register, such as onClick.fn
- the name (String
) of the member method to handle the event,
or the function (Function
).
It is optional. If omitted, _doEvtnm is assumed, where evtnm
is the value passed thru the evtnm
argument.
For example, if the event name is onFocus, then the method is assumed to be
_doFocus.keyword
- the extra argumenet for the function, which is passed
into the callback function. (since 7.0)domUnlisten_(_global_.DOMElement, _global_.String, zk.Object, _global_.String)
protected Widget domUnlisten_(DOMElement node, String evtnm, Object fn, String keyword)
Refer to domListen_(_global_.DOMElement, _global_.String, zk.Object, _global_.String)
for more information.
node
- a node of this widget.
It is usually retrieved by $n(_global_.String)
.evtnm
- the event name to register, such as onClick.fn
- the name (String
) of the member method to handle the event,
or the function (Function
).
It is optional. If omitted, _doEvtnm is assumed, where evtnm
is the value passed thru the evtnm
argument.
For example, if the event name is onFocus, then the method is assumed to be
_doFocus.keyword
- the extra argumenet for the function, which is passed
into the callback function. (since 7.0)domListen_(_global_.DOMElement, _global_.String, zk.Object, _global_.String)
protected void listenOnFitSize_()
unlistenOnFitSize_()
protected void unlistenOnFitSize_()
listenOnFitSize_()
public Offset fromPageCoord(int x, int y)
x
- the X coordinate related to the browser windowy
- the Y coordinate related to the browser windowprotected boolean isWatchable_(String name, Widget p, Map cache)
zWatch
to check if the given watch shall be firedname
- the name of the watch, such as onShowp
- the parent widget causing the watch event.
It is null if it is not caused by zWatch.fireDown(_global_.String, java.lang.Object, _global_.Map, java.lang.Object...)
.cache
- a map of cached result (since 5.0.8). Ignored if null.
If specified, the result will be stored and used to speed up the processingprotected boolean ignoreDescendantFloatUp_()
Default: false.
protected void shallFireSizedLaterWhenAddChd_()
public Widget set(String name, Object value, Object extra)
name
- the name of property.
Refer to set(String, Object)
for special names.value
- the valueextra
- the extra argument. It could be anything.public Widget set(String name, Object value)
If the name starts with on
, it is assumed to be
an event listener and setListener(_global_.String, _global_.Function)
will be called.
If the name starts with $on
, the value is assumed to
be a boolean indicating if the server registers a listener.
If the name starts with $$on
, it indicates
the event is an important event that the client must send it
back to the server. In additions, the value is assumed to
be a boolean indicating if the server registers a listener.
If the value is in this format, it indicates $u
's
value is UUID of a widget, and it will be resolved to a widget
before calling the real method.
However, since we cannot resolve a widget by its UUID until
the widget is bound (to DOM). Thus, ZK sets property after mounted.
For example, wgt.set("radiogroup", {$u: uuid})
is equivalent
to the following.
zk.afterMount(function () {
wgt.set("radiogroup", zk.Widget.$(uuid))
});
name
- the name of property.value
- the valueprotected void bindSwipe_()
You rarely need to override this method, unless you want to bind swipe behavior differently.
Default: use Swipe
to implement swipe event.
doSwipe_(zk.Event)
protected void unbindSwipe_()
You rarely need to override this method, unless you want to unbind swipe event differently.
doSwipe_(zk.Event)
protected void bindDoubleTap_()
You rarely need to override this method, unless you want to implement double click behavior differently.
doDoubleClick_(zk.Event)
protected void unbindDoubleTap_()
You rarely need to override this method, unless you want to implement double click behavior differently.
doDoubleClick_(zk.Event)
protected void bindTapHold_()
You rarely need to override this method, unless you want to implement right click behavior differently.
doRightClick_(zk.Event)
protected void unbindTapHold_()
You rarely need to override this method, unless you want to implement right click behavior differently.
doRightClick_(zk.Event)
public static Widget $(Object n, Map opts)
n
- the object to look for. If it is a string,
it is assumed to be UUID, unless it starts with '$'.
For example, zk.Widget.$('uuid')
is the same as zk.Widget.$('#uuid')
,
and both look for a widget whose ID is 'uuid'. On the other hand,
zk.Widget.$('$id')
looks for a widget whose ID is 'id'.zk.Widget.$('.className') looks for a widget whose CSS selector is 'className'. (since zk 8.0)
If it is an DOM element (DOMElement
), it will look up
which widget it belongs to.
If the object is not a DOM element and has a property called
target
, then target
is assumed.
Thus, you can pass an instance of Event
or Event
,
and the target widget will be returned.
opts
- [optional] the options. Allowed values:
$n(_global_.String)
). In most cases, if ID
of an element is xxx-yyy, the the element must be a child of
the element whose ID is xxx. However, there is some exception
such as the shadow of a window.protected static void mimicMouseDown_(Widget wgt, boolean noFocusChange, int which)
However, it is useful if the widget you are implemented will 'eat' the mouse-down event so ZK Client Engine won't be able to intercept it at the document level.
wgt
- the widget that receives the mouse-down eventnoFocusChange
- whether zk.currentFocus shall be changed to wgt.which
- the button number that was pressed.public static Array getElementsByName(String name)
name
- the widget name widgetName
.DOMElement
public static Array getElementsById(String id)
id
- the id of a widget, id
.DOMElement
public static String uuid(String subId)
subId
- the ID of a DOM elementpublic static String nextUuid()
This method is called automatically if $init(_global_.Map)
is called without uuid.
public static boolean isAutoId(String uuid)
uuid
- the UUID to testpublic static void register(String clsnm, boolean blankPreserved)
className
, getClass(_global_.String)
, and newInstance(_global_.String, _global_.Map)
won't be applicable.
Notice that the class must be declared before calling this method. In other words, zk.$import(clsnm) must return the class of the specified class name.
zk.Widget.register('foo.Cool'); //class name
zk.Widget.getClass('cool'); //widget name
clsnm
- the class name, such as zul.wnd.WindowblankPreserved
- whether to preserve the whitespaces between child widgets when declared in iZUML. If true, a widget of clsnm will have a data member named blankPreserved (assigned with true). And, iZUML won't trim the whitespaces (aka., the blank text) between two adjacent child widgets.public static Class getClass(String wgtnm)
zk.Widget.getClass('combobox');
Notice that null is returned if the widget is not loaded (or not exist) yet.
wgtnm
- the widget name, such as textbox.newInstance(_global_.String, _global_.Map)
,
register(_global_.String, boolean)
public static Widget newInstance(String wgtnm, Map props)
This method is usually used by tools, such as zk.zuml.Parser, rather than developers, since developers can create the widget directly if he knows the class name.
wgtnm
- the widget name, such as textbox.props
- [optional] the properties that will be passed to
$init(_global_.Map)
.getClass(_global_.String)
,
register(_global_.String, boolean)
Copyright © 2005-2023 Potix Corporation. All Rights Reserved.