public class Object
extends java.lang.Object
Class
Modifier and Type | Field and Description |
---|---|
Class |
$class
The class that this object belongs to.
|
int |
$oid
The object ID.
|
Modifier and Type | Method and Description |
---|---|
void |
$init()
The constructor.
|
boolean |
$instanceof(Class klass)
Determines if this object is an instance of the class represented by the specified Class parameter.
|
Object |
$super(Class klass,
String mtd,
Object... vararg)
Invokes a method defined in the superclass with any number of arguments.
|
Object |
$super(String mtd,
Object... vararg)
Invokes a method defined in the superclass with any number of arguments.
|
Object |
$supers(Class klass,
String mtd,
Array args)
Invokes a method defined in the superclass with an array of arguments.
|
Object |
$supers(String mtd,
Array args)
Invokes a method defined in the superclass with an array of arguments.
|
void |
afterInit(Function func)
Specifies a function that shall be called after the object is initialized,
i.e., after
$init() is called. |
static boolean |
isAssignableFrom(Class cls)
Determines if the class by this Class object is either the same as, or is a superclass of, the class represented by the specified Class parameter.
|
static boolean |
isInstance(Object o)
Determines if the specified Object is assignment-compatible with this Class.
|
Function |
proxy(Function func)
Proxies a member function such that it can be called with this object in a context that this object is not available.
|
public Class $class
public int $oid
Trick: you can test if a JavaScript object is a ZK object by examining this property, such as
if (o.$oid) alert('o is a ZK object');
Notice: zk.Class extends from zk.Object (so a class also has $oid)
public void afterInit(Function func)
$init()
is called. This method can be called only during the execution of $init()
.
It is an advance feature that is used to allow a base class to do something that needs to wait for all deriving classes have been initialized.
Invocation Sequence:
func
- the function to register for execution later$init()
public boolean $instanceof(Class klass)
if (obj.$instanceof(zul.wgt.Label, zul.wgt.Image)) {
}
klass
- the Class object to be checked.
Any number of arguments can be specified.public Object $super(Class klass, String mtd, Object... vararg)
It is similar to $super(String, Object...)
, but
this method works even if the superclass calls back the same member method.
In short, it is tedious but safer.
Example:
foo.MyClass = zk.$extends(foo.MySuper, {
multiply: function (n) {
return this.$super(foo.MyClass, 'multiply', n + 2);
}
Notice that the class specified in the first argument is not the super class having the method. Rather, it is the class that invokes this method.
klass
- the class that invokes this method.mtd
- the method name to invokevararg
- any number of arguments$supers(zk.Class, _global_.String, _global_.Array)
public Object $super(String mtd, Object... vararg)
Example:
multiply: function (n) {
return this.$super('multiply', n + 2);
}
mtd
- the method name to invokevararg
- any number of arguments$supers(zk.Class, _global_.String, _global_.Array)
public Object $supers(Class klass, String mtd, Array args)
It is similar to $supers(String, Array)
, but
this method works even if the superclass calls back the same member method.
In short, it is tedious but safer.
Example:
foo.MyClass = zk.$extends(foo.MySuper, {
multiply: function () {
return this.$supers(foo.MyClass, 'multiply', arguments);
}
Notice that the class specified in the first argument is not the super class having the method. Rather, it is the class that invokes this method.
klass
- the class that invokes this method.mtd
- the method name to invokeargs
- an array of arguments. In most case, you just pass
arguments
(the built-in variable).$super(zk.Class, _global_.String, zk.Object...)
public Object $supers(String mtd, Array args)
Example:
multiply: function () {
return this.$supers('multiply', arguments);
}
mtd
- the method name to invokeargs
- an array of arguments. In most case, you just pass
arguments
(the built-in variable).$super(zk.Class, _global_.String, zk.Object...)
public Function proxy(Function func)
Example: Let us say if you want a member function to be called periodically, you can do as follows.
setInterval(wgt.proxy(wgt.doIt), 1000); //assume doIt is a member function of wgt
With proxy, when doIt is called, this references to wgt. On the other hand, the following won't work since this doesn't reference to wgt, when doIt is called.
setInterval(wgt.doIt, 1000); //WRONG! doIt will not be called with wgt
Notice that this method caches the result so that it will return the same proxied function, if you pass the same function again.
func
- a method member of this objectthis
referencing to this object).public void $init()
Default: it does nothing so the subclass needs not to copy back (also harmless to call back).
afterInit(_global_.Function)
public static boolean isInstance(Object o)
if (klass.isInstance(obj)) {
}
o
- the object to checkpublic static boolean isAssignableFrom(Class cls)
if (klass1.isAssignableFrom(klass2)) {
}
cls
- the Class object to be checked, such as zk.Widget.Copyright © 2005-2023 Potix Corporation. All Rights Reserved.