Function zk

  • Parameters

    • Optional sel: null | string | Node | JQuery<HTMLElement> | Event | Event<unknown> | Widget<HTMLElement>

    Returns zjq

Namespaces

Classes

Type Aliases

Properties

Methods

Properties

APM: string[]
Buffer: typeof Array
DECIMAL: string

The character used for decimal sign.

DOW_1ST: number
DnD: typeof __class = ...
ERA: string
FDOW: string[]
FMON: string[]
GROUPING: string

The character used for thousands separator.

IMAGEMAP_DONE_URI: string | undefined
LAN_TAG: string
MINDAYS: number
MINUS: string

The character used to represent minus sign.

NoDOM: typeof NoDOM = ...
Object: typeof ZKObject
PERCENT: string

The character used for percent sign.

PER_MILL: string

The character used for mille percent sign.

S2DOW: string[]
S2MON: never
SDOW: string[]
SMON: string[]
TDYS: number
YDELTA: number
_noESC: number
agent: string

The user agent of the browser.

alerting: boolean

Indicates whether an OS-level modal dialog is opened. In this case, onblur will be called so a widget can use it to decide whether to validate.

android: boolean
appName: string

The application's name, which will be initialized as server-side's WebApp.getAppName(). It will be used as title of jq.alert.

Since

5.0.6

ausending: boolean
bmk: {
    checkBookmark: (() => void);
    bookmark(nm, replace): void;
    onIframeLoaded(src): void;
    onURLChange(): void;
} = ...

Type declaration

  • checkBookmark: (() => void)
      • (): void
      • Checks whether the bookmark is changed.

        Returns void

  • bookmark:function
    • Sets a bookmark that user can use forward and back buttons

      Parameters

      • nm: string
      • replace: boolean

      Returns void

  • onIframeLoaded:function
    • called when bookmark.html is loaded

      Parameters

      • src: string

      Returns void

  • onURLChange:function
    • check if URL is changed

      Returns void

booted: boolean

Indicates whether ZK Client Engine has been booted and created the initial widgets. It is useful to know if it is caused by an asynchronous update (i.e., zk.booted is true).

build: string

The build of ZK, such as '08113021'

busy: number

Indicates if the application is busy. It is actually a number that is increased when zk.AuCmd0.showBusy is called, and decreased when zk.AuCmd0.clearBusy is called. In other words, it is set by the application, and used to indicate the application (rather than ZK) is busy.

Since

5.0.1

cfrg: [number, number] | undefined
chrome: undefined | boolean
classes: Record<number, unknown>

A map of all classes, Map<int oid, zk.Class cls>.

Since

5.0.8

clickPointer: Offset

The last position that the mouse was clicked (including left and right clicks).

clientinfo: Record<string, unknown> | undefined
confirmClose: string | undefined
contextURI: string | undefined
css3: boolean

Whether it supports CSS3.

currentFocus: undefined | Widget<HTMLElement>

The widget that gains the focus now, or null if no one gains focus now.

currentModal: undefined | Window

The topmost modal window, or null if no modal window at all.

currentPointer: Offset

The position of the mouse (including mouse move and click).

dataHandlers: Record<string, string | DataHandler> | undefined
debugJS: boolean | undefined
delayQue: Record<string, Function[]> = {}
dragging: boolean
edge: undefined | string | false
edge_legacy: undefined | string | number | false
feature: {
    ee?: boolean;
    pe?: boolean;
    standard?: boolean;
}

Type declaration

  • Optional ee?: boolean
  • Optional pe?: boolean
  • Optional standard?: boolean
ff: string | number | false | undefined

The version as double (only the first two part of the version, such as 3.6) if it is Firefox, such as Firefox. Notice that it is Firefox's version, such as 3.5, 3.6 and 4.0. If not a firefox, it is null.

Since

5.0.6

focusBackFix: boolean | undefined
gecko: string | number | false | undefined

The version as double (only the first two part of the version, such as 3.5) if it is Gecko-based browsers, such as Firefox.

groupingDenied: boolean
historystate: {
    enabled: boolean;
    onPopState(event): void;
    register(): void;
} = ...

Type declaration

  • enabled: boolean
  • onPopState:function
    • Parameters

      • event: PopStateEvent

      Returns void

  • register:function
    • Returns void

ios: undefined | string | boolean
ipad: undefined | string | boolean
isTimeout: boolean
keepDesktop: boolean
keyCapture: Widget | undefined

The widget that captures the keystrokes. Used to specify a widget that shall receive the following the onKeyPress and onKeyUp events, no matter what widget the event occurs on.

doKeyDown_: function () {
zk.keyCapture = this;
this.$supers('doKeyDown_', arguments);
}

Notice that the key capture is reset automatically after processing onKeyUp_.

linux: boolean
loading: number

The number of widget packages (i.e., JavaScript files) being loaded (and not yet complete).

When the JavaScript files of widgets are loading, you shall not create any widget. Rather, you can use afterLoad to execute the creation and other tasks after all required JavaScript files are loaded.

mac: boolean
mobile: string | boolean
mounting: boolean

Whether ZK Client Engine has been mounting the peer widgets. By mounting we mean the creation of the peer widgets under the control of the server. To run after the mounting of the peer widgets, use afterMount

mouseCapture: Widget | undefined

The widget that captures the mouse events. Used to specify a widget that shall receive the following the onMouseMove and onMouseUp events, no matter what widget the event occurs on.

doMouseDown_: function () {
zk.mouseCapture = this;
this.$supers('doMouseDown_', arguments);
}

Notice that the mouse capture is reset automatically after processing onMouseUp_.

opera: string | number | false | undefined

The version as double (only the first two part of the version, such as 10.1) if it is Opera, or null if not.

override: {
    <T, U>(dst, backup, src): T & U;
    <T>(oldfunc, newfunc): T;
    <T>(dst, nm, val): T;
}

Type declaration

    • <T, U>(dst, backup, src): T & U
    • Overrides the properties of a map. It is similar to zk.copy, except

      1. It preserves the original member (method or data) in the backup argument.
      2. It handles the class extensions (zk.$extends) well. For example, the members of all deriving classes will be overriden too, if necessary.

      Example, ```ts var _xCombobox = {} zk.override(zul.inp.Combobox.prototype, _xCombobox, { redrawpp_: function (out) { if (!_redrawpp(this, out)) _xCombobox.redrawpp_.apply(this, arguments); //call the original method }, open: function () { _renderpp(this); _xCombobox.open.apply(this, arguments); //call the original method } }); ```

      Type Parameters

      • T

      • U

      Parameters

      • dst: T

        the destination object to override

      • backup: Record<string, unknown>

        the map used to store the original members (or properties)

      • src: U & Partial<T> & ThisType<T & U>

        the source map providing the new members

      Returns T & U

      the destination object

    • <T>(oldfunc, newfunc): T
    • Overrides a particular method. The old method will be returned, and the caller could store it for calling back. For example,

      var superopen = zk.override(zul.inp.Combobox.prototype.open,
      function () {
      superopen.apply(this, arguments);
      //do whatever you want
      });

      Type Parameters

      • T extends (() => void)

      Parameters

      • oldfunc: T

        the old function that will be replaced

      • newfunc: (() => void)

        the new function that will replace the old function

          • (): void
          • Returns void

      Returns T

      the old function (i.e., oldfunc)

      Since

      5.0.6

    • <T>(dst, nm, val): T
    • Overrides a particular method or data member. The old method will be stored in method called $nm (assuming nm is the method name to override. For example,

      zk.override(zul.inp.Combobox.prototype, {},
      open() {
      this.$open.apply(this, arguments);
      //do whatever you want
      }
      );

      Type Parameters

      • T

      Parameters

      • dst: T

        the destination object to override

      • nm: string

        the method name to override

      • val: (() => void)

        the value of the method. To override a method, it has to be an instance of Function.

          • (): void
          • Returns void

      Returns T

      the destination object

      Since

      5.0.2

pfmeter: boolean
pi: number | undefined
portlet2Data: Record<string, {
    namespace: string;
    resourceURL: string;
}> | undefined
procDelay: number

The delay before showing the processing prompt (unit: milliseconds).

Default Value

900 (depending on the server's configuration)

processMask: boolean | undefined
processing: boolean

Whether Client Engine is processing something, such as processing an AU response. This flag is set when startProcessing is called, and cleaned when endProcessing is called.

progPos: string | undefined
regClass: (<S>(jclass) => S)

Type declaration

    • <S>(jclass): S
    • Type Parameters

      Parameters

      • jclass: S

      Returns S

resendTimeout: number

The timeout for re-sending AU request (unit: milliseconds).

Default Value

200 (depending on the server's configuration)

Since

6.5.2

resourceURI: string | undefined
rmDesktoping: boolean
safari: boolean | undefined

The version as double (only the first two part of the version, such as 533.1) if it is Safari-based, or null if not.

scriptErrorHandler: ((evt) => void) | undefined

Type declaration

    • (evt): void
    • Parameters

      • evt: any

      Returns void

scriptErrorHandlerEnabled: boolean
scriptErrorHandlerRegistered: boolean
sendClientErrors: boolean | undefined
set: {
    <T>(o, name, value, extra): T;
    <T, U>(dst, src, props, ignoreUndefined): T;
}

Type declaration

    • <T>(o, name, value, extra): T
    • Assigns a value to the specified property.

      For example, `zk.set(obj, "x", 123)`:
      If setX is defined in obj, obj.setX(123) is called. If not defined, obj.x = 123 is called.

      Anotehr example: ```ts zk.set(o, 'value', true); //set a single property ```

      Type Parameters

      • T

      Parameters

      • o: T

        the object to assign values to

      • name: string

        the property's name

      • value: unknown

        the property's value

      • extra: Record<string, unknown>

        an extra argument to pass to the setX method as the extra argument (the second argument). For example, zk.set(obj, 'x', 123, true) invokes obj.setX(123, true).

      Returns T

      the destination object

      See

      get

    • <T, U>(dst, src, props, ignoreUndefined): T
    • Sets the given properties from one object to another. Example:

      zk.set(dst, src, ["foo", "mike"]);
      

      If dst has a method called setFoo and src has method called getMike, then it is equivalent to

      dst.setFoo("foo", src["foo"]);
      dst["mike"] = src.getMike();

      Type Parameters

      Parameters

      • dst: T

        the destination object to copy properties to

      • src: U

        the source object to copy properties from

      • props: string[]

        an array of property names (String)

      • ignoreUndefined: boolean

        whether to ignore undefined. Optional (if not specified, false is assumed). If true and src[name] is undefined, then dst[name] won't be assigned.

      Returns T

      the destination object

      Since

      5.0.3

      See

      zk.copy

skipBfUnload: boolean
spaceless: boolean

Indicates whether Widget#id is always the same as Widget#uuid.

By default, it is false.

You could enable it if the pure-client approach is taken, since it is more convenient. However, it also means the concept of ID space is no longer valid.

tabletUIEnabled: boolean

Indicates whether to enable the tablet UI.

Since

9.5.1

themeName: string | undefined
timeout: number
timerAlive: boolean
tipDelay: number

The delay before showing a tooltip (unit: milliseconds).

Default Value

800 (depending on the server's configuration)

touchEnabled: boolean

Indicates whether to apply touch mode.

Since

9.5.1

unloading: boolean

Indicates whether the browser is unloading this document. Note: when the function registered with beforeUnload is called, this flag is not set yet.

updateURI: string | undefined
useStackup: string | boolean | undefined
vendor: string
vendor_: string
version: string

The version of ZK, such as '5.0.0'

visibilitychange: boolean
webkit: undefined | boolean
xhrWithCredentials: boolean

Methods

  • Retrieves the widget.

    Type Parameters

    Parameters

    • Optional n: null | string | Node | JQuery<HTMLElement> | Event | Event<unknown> | T

      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'.
      and 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 jq.Event or zk.Event, and the target widget will be returned.

    • Optional opts: Partial<{
          child: boolean;
          exact: boolean;
          strict: boolean;
      }>

      the options. Allowed values:

      • exact - id must exactly match uuid (i.e., uuid-xx ignored). It also implies strict (since 5.0.2)
      • strict - whether not to look up the parent node.(since 5.0.2) If omitted, false is assumed (and it will look up parent).
      • child - whether to ensure the given element is a child element of the widget's main element (Widget.$n). 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.

    Returns undefined | T

  • Provides the default values for the specified options.

    Example: ```ts process: function (opts, defaultOptions) { opts = zk.$default(opts, defaultOptions); } ``` ```ts opts = zk.$default(opts, {timeout: 100, max: true}); //timeout and max are assigned to opts only if no such property found in opts ```

    Type Parameters

    • T

    • U

    Parameters

    • opts: T

      a map of options to which default options will be added If null, an empty map is created automatically.

    • defaults: U

      a map of default options

    Returns T & U

    the merged options

  • Defines a class. It returns the class being defined.

    Example: ```ts zul.Label = zk.$extends(zk.Widget, { _value: '', getValue() { return this._value; }, setValue(value) { this._value = value; } }); ```

    $define

    To simplify the declaration of the getters and setters, `$define` is introduced. It is shortcut to invoke define. For example, ```ts foo.Widget = zk.$extends(zk.Widget, { _value: '', $define: { name: null, value: null }, bind_: function () { // } }); ```

    is equivalent to ```ts foo.Widget = zk.$extends(zk.Widget, { _value: '', bind_: function () { // } }); zk.define(foo.Widget, { name: null, value: null }); ```

    is equivalent to ```ts foo.Widget = zk.$extends(zk.Widget, { _value: '', getName: function () { return this._name; }, setName: function (v) { this._name = v; return this; }, getValue: function () { return this._value; }, setValue: function (v) { this._value = v; return this; }, bind_: function () { // } }); ```

    Type Parameters

    Parameters

    • superclass: S

      the super class to extend from

    • members: D & ThisType<D>

      a map of non-static members

    • Optional staticMembers: D2

      a map of static members. Ignored if omitted.

    Returns S

    the class being defined

  • Imports a class or a package. It returns null if the package or class is not defined yet. It returns null if the package or class is not defined yet and fn is null.

    If an additional function, `fn` is specified, this method assumes `name` is a class and it will load the package of the class first. If not found. Then, invoke the function after the class is loaded. For example, the following creates a Listbox widget after loading the package.

    Example: ```ts var foo = zk.$import('com.foo'); var cool = new foo.Cool(); var Cool = zk.$import('com.foo.Cooler'); var cooler = new Cooler();

    zk.$import('zul.sel.Listbox', function (cls) {new cls();}); ```

    Parameters

    • name: string

      The name of the package or the class.

    • Optional fn: CallableFunction

      The function to call after the class is loaded.

    Returns unknown

    a package (Package) or a class (Class)

  • Intercepts a widget, when specific method has been called, the interceptor would be called first.

    Example, ```ts zk.$intercepts(zul.inp.Combobox, { open: function () { var context = this.$getInterceptorContext$(); console.log('open'); context.stop = false; } }); ```

    In the interceptor function, you could call this.$getInterceptorContext$() to get the context object. The context object has several properties, it would help you the deal with the interceptor:

    • context.stop - whether to call the original method in the widget.
    • context.result - the return value of the widget function.
    • context.args - the original arguments in the function of widget, you could update it for calling the original method.

    Parameters

    • targetClass: typeof ZKObject

      the destination object to override

    • interceptor: object | Record<string, CallableFunction>

      the interceptor map corresponds to the widget methods

    Returns void

    Since

    8.0.3

  • Defines a package. It creates and returns the package if not defined yet. If the package is already defined, it does nothing but returns the package. It is similar to Java's package statement except it returns the package object.

    Notice the package is usually defined automatically by use of WPD, so you're rarely need to use this method.

    Example: ```ts var foo = zk.$package('com.foo'); foo.Cool = zk.$extends(zk.Object); ```

    Parameters

    • name: string

      the name of the package.

    • Optional end: boolean
    • Optional wv: boolean

    Returns unknown

    Package

  • A does-nothing-but-returns-false function.

    Returns false

  • Parameters

    • pkg: string

    Returns (<T>(constr) => T)

      • <T>(constr): T
      • Type Parameters

        Parameters

        • constr: T

        Returns T

  • Adds data attribute handler

    Parameters

    • name: string

      the attribute name

    • script: string

      the JS content

    Returns void

    Since

    8.0.0

  • Executes a function only when no animation is taking place. If there is some animation, the specified function will be queued and invoked after the animation is done.

    If the delay argument is not specified and no animation is taking place, the function is executed with `setTimeout(fn, 0)`.

    Parameters

    • fn: (() => void)

      the function to execute

        • (): void
        • Returns void

    • Optional delay: number

      (int) how many milliseconds to wait before execute if there is no animation is taking place. If omitted, 0 is assumed. If negative, the function is executed immediately.

    Returns boolean | void

    true if this method has been called before return (delay must be negative, and no animation); otherwise, undefined is returned.

    See

    zk.animating

    Since

    5.0.6

  • Adds a function that will be executed after onResponse events are done. That means, after au responses, the function added in the afterAuResponse() will be invoked

    Parameters

    • fn: (() => void)

      the function to execute after au responses

        • (): void
        • Returns void

    Returns void

    Since

    7.0.6

  • Declares a function that shall be executed after all requested packages are loaded (i.e., loading is 0). If all packages has been loaded, the function is executed immediately and this method returns true.

    Parameters

    • func: CallableFunction

      the function to execute

    Returns boolean

    whether func has been executed

  • Declares a function that shall be executed only if the specified package(s) are loaded (and loading is 0). Notice that it won't cause the package(s) to execute. Rather, it defers the execution of the specified function until someone else loads the package (by use of load).

    See also JavaScript Packaging

    To know whether all requested packages are loaded (i.e., ZK is not loading any package), you can check loading if it is 0.

    Notice that functions specified in the second format execute before those specified in the first format.

    Example ```ts zk.afterLoad('foo', function() {new foo.Foo();}); zk.afterLoad('foo1,foo2', function() {new foo1.Foo(foo2.Foo);}); zk.afterLoad(function() {}); ```

    Parameters

    • pkgs: string

      the package(s) that the specified function depends on. In other words, the function is evaluated only if the package(s) are loaded. If you want to specify multiple packages, separate them with comma.

    • func: CallableFunction

      the function to execute

    • Optional front: boolean

    Returns void

  • Adds a function that will be executed after the mounting is done. By mounting we mean the creation of peer widgets.

    By mounting we mean the creation of the peer widgets under the control of the server. To run after the mounting of the peer widgets,

    If the delay argument is not specified and no mounting is taking place, the function is executed with `setTimeout(fn, 0)`.

    Parameters

    • Optional fn: (() => void)

      the function to execute after mounted

        • (): void
        • Returns void

    • Optional delay: number

      (since 5.0.6) how many milliseconds to wait before execute if there is no mounting taking place. If omitted, 0 is assumed. If negative, the function is executed immediately (if no mounting is taking place).

    Returns boolean

    true if this method has been called before return (delay must be negative, and no mounting); otherwise, undefined is returned.

  • Adds a function that will be executed after all of the onSize events are done.

    Here lists the execution phases:

    1. After the page loaded, the function added in the afterResze() will be invoked
    2. After the browser resized, the function added in the afterResze() will be invoked
    3. After zWatch.fire/fireDown('onSize'), the function added in the afterResze() will be invoked

    Parameters

    • fn: (() => void)

      the function to execute after resized

        • (): void
        • Returns void

    Returns void

    Since

    6.5.2

  • Encodes and returns the resource URI from Class-Web Resources (CWR). Example:

    var res = zk.ajaxResourceURI('/js/my/path/res.css');
    

    Parameters

    • uri: string

      the resource URI.

    • Optional version: string

      the version string to build the cache-friendly URI. If none is set, use zk.build by default.

    • Optional opts: Partial<AjaxURIOptions>

      the options. Allowed values:

      • au - whether to generate an URI for accessing the ZK update engine. If not specified, it is used to generate an URL to access any servlet
      • desktop - the desktop or its ID. If null, the first desktop is used.
      • ignoreSession - whether to handle the session ID in the base URI.

    Returns string

    the encoded resource URI

    Since

    9.0.0

  • Encodes and returns the URI to communicate with the server. Example:

    document.createElement("script").src = zk.ajaxURI('/web/js/com/foo/mine.js',{au:true});
    

    Parameters

    • uri: undefined | string

      the URI related to the AU engine. If null, the base URI is returned.

    • Optional opts: Partial<AjaxURIOptions>

      the options. Allowed values:

      • au - whether to generate an URI for accessing the ZK update engine. If not specified, it is used to generate an URL to access any servlet
      • resource - whether to generate an URI for accessing the ZK resource engine. If not specified, it is used to generate an URL to access any servlet
      • desktop - the desktop or its ID. If null, the first desktop is used.
      • ignoreSession - whether to handle the session ID in the base URI.

    Returns string

    the encoded URI

  • Returns boolean

    whether there is some animation taking place. If you'd like to have a function to be called only when no animation is taking place (such as waiting for sliding down to be completed), you could use zk.afterMount.

  • Replaces existing properties and add new properties. It is similar to zk.override, except

    1. It preserves the overwritten members (methods or data) in the return value.
    2. It handles the class extensions (zk.$extends) well. For example, the members of all deriving classes will be overriden too, if necessary.
    3. Overlapping properties must have identical types.

    Example, ```ts var _xCombobox = zk.augment(zul.inp.Combobox.prototype, { redrawpp_: function (out) { if (!_redrawpp(this, out)) _xCombobox.redrawpp_.apply(this, arguments); //call the original method }, open: function () { _renderpp(this); _xCombobox.open.apply(this, arguments); //call the original method } }); ```

    Type Parameters

    • D extends Pick<S, keyof D & keyof S>

    • S

    Parameters

    • dst: D

      the destination object to override

    • src: S & Pick<D, keyof D & keyof S> & ThisType<D & S>

      the source map providing the new members

    Returns Pick<D, keyof D & keyof S>

    the backup object

    Since

    10.0.0

  • Adds a function that will be executed when the browser is about to unload the document. In other words, it is called when window.onbeforeunload is called.

    To remove the function, invoke this method by specifying remove to the opts argument. ```ts zk.beforeUnload(fn, {remove: true}); ```

    Parameters

    • fn: (() => undefined | string)

      the function to execute. The function shall return null if it is OK to close, or a message (String) if it wants to show it to the end user for confirmation.

        • (): undefined | string
        • Returns undefined | string

    • Optional opts: {
          remove: boolean;
      }

      a map of options. Allowed vlaues:

      • remove: whether to remove instead of add.
      • remove: boolean

    Returns void

  • Copies a map of properties (or options) from one object to another and optionally copies the original value to another map. Example: extending Array

    zk.copy(Array.prototype, {
    $addAll: function (o) {
    return this.push(...o);
    }
    });

    Example: copy style and restore back

    var backup = {};
    zk.copy(n.style, {
    visibility: 'hidden',
    position: 'absolute',
    display: 'block'
    }, backup);
    try {
    //do whatever
    } finally {
    zk.copy(n.style, backup);
    }

    Notice that zk.copy copies the properties directly regardless if the target object has a setter or not. It is fast but if you want to go thru the setter, if any, use set instead.

    Type Parameters

    • T

    • U

    Parameters

    • dst: T

      the destination object to copy properties to

    • src: U

      the source object to copy properties from

    • Optional backup: Record<string, unknown>

      the map to stor the original value

    Returns T & U

    the destination object

    Since

    5.0.3

  • Retrieves and removes the value of the specified name of the given map.

    Type Parameters

    • T

    Parameters

    • props: Record<string, T>

      a map of properties

    • nm: string

      the name to retrieve the value

    Returns undefined | T

    the value.

    Since

    5.0.2

  • If in debug-js, use console log to display an log message to indicate an debug log. Example:

    zk.debugLog('Oops! Something wrong:(');
    

    Parameters

    • msg: string

      the warning message

    Returns void

    Since

    8.5.0

  • Defines the setter and getter methods.

    Notice that you rarely need to invoke this method directly. Rather, you can specify them in a property named $define, when calling #$extends.

    For example, the following code snippet ```ts zk.define(zul.wgt.Button, { disabled: null }); ```

    is equivalent to define three methods, isDisabled, getDisabled and setDisabled, as follows:

    zul.wgt.Button = zk.$extends(zk.Widget, {
    isDisabled: _zkf = function () {
    return this._disabled;
    },
    isDisabled: _zkf,
    setDisabled: function (v) {
    this._disabled = v;
    return this;
    }
    });

    If you want to do something when the value is changed in the setter, you can specify a function as the value in the props argument. For example,

    zk.define(zul.wgt.Button, {
    disabled: function () {
    if (this.desktop) this.rerender();
    }
    });

    will cause the setter to be equivalent to

    setDisabled: function (v, opts) {
    this._disabled = v;
    if (this._disabled !== v || opts?.force)
    if (this.desktop) this.rerender();
    return this;
    }

    If you want to pre-process the value, you can specify a two-element array. The first element is the function to pre-process the value, while the second is to post-process if the value is changed, as described above. For example,

    zk.define(zul.wgt.Button, {
    disabled: [
    function (v) {
    return v != null && v != false;
    },
    function () {
    if (this.desktop) this.rerender();
    }
    ]
    });

    will cause the setter to equivalent to

    setDisabled: function (v) {
    v = v != null && v != false;
    this._disabled = v;
    if (this._disabled !== v || opts?.force)
    if (this.desktop) this.rerender();
    return this;
    }

    Notice that when the function (specified in props) is called, the arguments are the same as the arguments passed to the setter (including additional arguments. For example, if button.setDisabled(true, false) is called, then the specified function is called with two arguments, true and false. In additions, as shown above, you can enforce the invocation of the function by passing a map with force as true.

    wgt.setSomething(somevalue, {force:true});
    

    Parameters

    • klass: NewableFunction

      the class to define the members

    • props: Record<string, CallableFunction | CallableFunction[]>

      the map of members (aka., properties)

    Returns NewableFunction

    the class being defined

  • Execute function related to specified widget after a while, and will insure the execution order.

    Parameters

    • uuid: string

      wgt's uuid

    • func: (() => void)

      a function to be executed

        • (): void
        • Returns void

    • Optional opts: Partial<{
          timeout: number;
          urgent: boolean;
      }>

      the options. Allowed options:

      • int timeout: number of milliseconds to wait before executing the function. Default: 50
      • boolean urgent: whether to execute function as soon as possible
      Note: timeout is only meaningful for the first function added to wgt

    Returns void

  • Declare a package that must be loaded when loading another package.

    Notice that it doesn't guarantee the loading order of the two packages. Thus, it is better to do in #afterLoad if a code snippet depends on both packages.

    Parameters

    • a: string

      the name of the package that depends another package. In other words, calling #loading against this package will cause dependedPkgnn being loaded.

    • b: string

      the name of the package that shall be loaded if another package is being loaded. In other words, it reads "a depends on b".

    Returns void

  • Disable the default behavior of ESC. In other words, after called, the user cannot abort the loading from the server.

    To enable ESC, you have to invoke enableESC and the number of invocations shall be the same.

    Returns void

  • Returns void

  • Returns void

  • Enables the default behavior of ESC (i.e., stop loading from the server).

    Returns void

  • Clears a flag, processing, to indicate that it the processing has done. It also removes a message, if any, that indicates "processing".

    Example: ```ts zk.startProcessing(1000); //do the lengthy operation zk.endProcessing(); ```

    Parameters

    • Optional pid: string | number

    Returns void

  • Display an error message to indicate an error. Example:

    zk.error('Oops! Something wrong:(');
    

    Parameters

    • err: string | Error

      the error or error message

    • Optional silent: boolean

      only show error box

    Returns void

  • Closes all error messages shown by error. Example:

    zk.errorDismiss();
    

    Returns void

  • Push an error message to the error box. Example:

    zk.errorPush('Oops! Something wrong:(');
    

    Parameters

    • msg: string

      the error message

    Returns void

    See

    zk.error

    Since

    10.0.0

  • Retrieves a value from the specified property.

    For example, `zk.get(obj, "x")`:
    If getX or isX is defined in obj, obj.isX() or obj.getX() is returned. If not defined, obj.x is returned.

    Another example: ```ts zk.get(o, 'value'); ```

    Parameters

    • o: ZKObject

      the object to retrieve value from

    • name: string

      the name

    Returns unknown

    the value of the property

  • Parameters

    • name: string

    Returns undefined | {
        run: ((wgt, dataValue) => void);
    }

    the dataHandler (with a run method) from the given name

    Since

    8.0.0

  • Parameters

    • pkg: string

      the package name

    • js: boolean

      whether the returned URL is used to load the JavaScript file. load will pass true to this argument to indicate the URI is used to load the JavaScript file. However, if you just want the URL to send the request back (such as json-p with jQuery's json), don't pass anything (or pass false) to this argument.

    Returns string

    the URI of the server (so called host) for the specified package.

    ZK Client Engine loads the packages from the same server that returns the HTML page. If a package might be loaded from a different server, you can invoke #setHost to specify it and then #getHost will return the correct URL for the specified package.

  • Parameters

    • pkg: string

      the package name

    Returns string | undefined

    the version of the specified package, or null if not available.

  • Test whether the name of the data attribute exists.

    Parameters

    • name: string

    Returns boolean

    true if existing.

    Since

    8.0.0

  • Parameters

    • cls: unknown

      the object to test whether it is a class (aka., a ZK class)

    Returns boolean

    if the given JS object is a class (zk.Class).

    Since

    5.0.9

  • Tests if a package is loaded (or being loaded).

    Parameters

    • pkg: string

      the package name

    • Optional loading: boolean

      [Optional; default: false] If true is specified, this method returns true if the package is loaded or being loaded. If false or omitted, it returns true only if the package is loaded.

    Returns boolean

    true if loaded

    See

    load

  • Parameters

    • o: unknown

      the object to test whether it is a ZK object

    Returns boolean

    whether the given JS object is a ZK object (zk.Object).

    Since

    5.0.9

  • Loads the specified package(s). This method is called automatically when mounting the peer widgets. However, if an application developer wants to access JavaScript packages that are not loaded, he has to invoke this method.

    The loading of a package is asynchronous, so you cannot create the widget immediately. Rather, use the `func` argument, func, or use #afterLoad to execute. ```ts zk.load('zul.utl', function () { new zul.utl.Timer(); }); ```

    Parameters

    • pkg: string

      the package name

    • Optional func: CallableFunction

      the function to execute after all packages are loaded. Ignored if omitted. Notice that func won't be executed until all requested packages are loaded; not just what are specified here.

    Returns boolean

    true if all required packages are loaded

  • Loads the specified package(s). This method is called automatically when mounting the peer widgets. However, if an application developer wants to access JavaScript packages that are not loaded, he has to invoke this method.

    The loading of a package is asynchronous, so you cannot create the widget immediately. Rather, use the `func` argument, func, or use #afterLoad to execute.

    Parameters

    • pkg: string

      the package name

    • Optional dt: Desktop

      the desktop used to get URI of the JavaScript file (ajaxURI). If null, the first desktop is assumed.

    • Optional func: CallableFunction

      the function to execute after all packages are loaded. Ignored if omitted. Notice that func won't be executed until all requested packages are loaded; not just what are specified here.

    Returns boolean

    true if all required packages are loaded

    See

    load

  • Loads a CSS file.

    Parameters

    • href: string

      the URL of the CSS file.

    • Optional id: string

      the identifier. Ignored if not specified.

    • Optional media: string

      the media attribute. Ignored if not specified.

    • Optional callback: CallableFunction

      function to execute after the CSS file loaded. (since 9.6.3)

    Returns void

    Since

    5.0.4

  • Loads a JavaScript file.

    Parameters

    • src: string

      the URL of the JavaScript file.

    • Optional name: string

      the name to shown up in the progressing dialog. Specify a non-empty string if you want ZK not to create widgets until this file is loaded. Ignored if not specified or null. If you specify a name here, you have to call setScriptLoaded when the script is loaded. Otherwise, zk.loading won't be zero and ZK Client Engine is halted.

    • Optional charset: string

      the charset. UTF-8 is assumed if null.

    • Optional force: boolean

      the script to be loaded. (no matter it is loading or loaded)

    • Optional callback: CallableFunction

      the function to execute after the JavaScript file loaded. (since 9.6.3)

    Returns void

  • Logs an message for debugging purpose. Example:

    zk.log('reach here');
    zk.log('value is", value);

    Parameters

    • detailed: any

      varient number of arguments to log

    Returns void

  • Parameters

    • Optional inp: MomentInput
    • Optional strict: boolean

      Strict parsing disables the deprecated fallback to the native Date constructor when parsing a string.

    Returns Moment

  • Parameters

    • Optional inp: MomentInput
    • Optional format: MomentFormatSpecification
    • Optional strict: boolean

      Strict parsing requires that the format and input match exactly, including delimiters. Strict parsing is frequently the best parsing option. For more information about choosing strict vs forgiving parsing, see the parsing guide.

    Returns Moment

  • Parameters

    • Optional inp: MomentInput
    • Optional format: MomentFormatSpecification
    • Optional language: string
    • Optional strict: boolean

      Strict parsing requires that the format and input match exactly, including delimiters. Strict parsing is frequently the best parsing option. For more information about choosing strict vs forgiving parsing, see the parsing guide.

    Returns Moment

  • Parses a string to a floating number.

    It is the same as the built-in parseFloat method except it never return NaN (rather, it returns 0).

    Parameters

    • v: undefined | string | number | boolean

      the text to parse

    Returns number

    the floating number

    Since

    5.0.2

  • Parses a string to an integer.

    It is the same as the built-in parseInt method except it never return NaN (rather, it returns 0).

    Parameters

    • v: undefined | string | number | boolean

      the text to parse

    • Optional b: number

      represent the base of the number in the string. 10 is assumed if omitted.

    Returns number

    the integer

  • Defines the URL of the host for serving the specified packages.

    Parameters

    • host: string

      the host, such as http://www.zkoss.org.

    • resURI: string

      the resource URI, such as /zkdemo/zkau, that is used to load the JavaScript files

    • pkgs: string[]

      an array of pckage names (String)

    Returns void

  • Parameters

    • pkg: string
    • Optional wait: boolean

    Returns void

  • Notify ZK that the name of the JavaScript file is loaded. This method is designed to be used with loadScript, such that ZK Client knows if a JavaScript file is loaded.

    Parameters

    • name: string

      the name of the JavaScript file. It must be the same as the one passed to loadScript.

    Returns void

  • Sets the version of the specified package.

    Parameters

    • pkg: string

      the package name

    • ver: string

      the version

    Returns void

  • Make a time stamp for this momemt; used for performance tuning. A time stamp is represented by a name. It is an easy way to measure the performance. At the end of executions, the time spent between any two stamps (including beginning and ending) will be logged (with zk.log).

    Parameters

    • Optional name: string

      the unique name to represent a time stamp

    • Optional noAutoLog: boolean

      whehter not to auto log the result. If omitted or false, zk.stamp will be invoked automatically to log the info and clean up all stamps after mounting is completed. Turn it off, if you prefer to invoke it manually.

      Logs the information of all stamps made by zk.stamp. After the invocation, all stamps are reset.

    Returns void

  • Set a flag, processing, to indicate that it starts a processing. It also shows a message to indicate "processing" after the specified timeout.

    Example: ```ts zk.startProcessing(1000); //do the lengthy operation zk.endProcessing(); ```

    Parameters

    • timeout: number

      the delay before showing a message to indicate "processing".

    • Optional pid: number

    Returns void

  • Declares the desktop is used for the stateless context. By stateless we mean the server doesn't maintain any widget at all.

    Parameters

    • Optional dtid: string

      the ID of the desktop to create

    • Optional contextURI: string

      the context URI, such as /zkdemo

    • Optional updateURI: string

      the update URI, such as /zkdemo/zkau

    • Optional resourceURI: string
    • Optional reqURI: string

      the URI of the request path.

    Returns Desktop

    the stateless desktop being created