Language Enhancement Utilities语言增强工具
char DECIMAL;
The character used for decimal sign.字符用于十进制签署。
char GROUPING;
The character used for thousands separator.字符用于成千上万的分隔符。
char MINUS;
The character used to represent minus sign.字符用于表示负号。
char PER_MILL
The character used for mille percent sign.字符用于bim百分号。
char PERCENT;
The character used for percent sign..字符用于百分号. .
boolean bootstrapping;
Indicates whether ZK Client Engine is just initialized and creating the initial widgets. ZK客户指示是否引擎只是���始化并创建初始窗口小部件。In other words, it is not caused by asynchronous update.换句话说,它并不是引起异步更新。
String build;
The build of ZK, such as '08113021'ZK的构建,比如‘08113021’
String confirmClose;
The message to show up before closing the browser window or navigating to other URL.消息出现之前关闭浏览器窗口或者导航到其他URL。
zk.Widgetzk.WidgetcurrentFocus;currentFocus;
The widget that gains the focus now, or null if no one gains focus now.这个小部件获得现在的焦点,或null如果没有人获得焦点现在。
Offset currentPointer;
The current mouse pointer.当前的鼠标指针。
zul.wnd.Window currentModal;
The topmost modal widow, or null if no modal window at all.最上层的模态的寡妇,或null如果没有模式窗口在所有。
zk.Widget keyCapture;
Used to specify a widget that shall receive the following the onKeyPress and onKeyUp events, no matter what widget the event occurs on.一个小部件,用于指定要受onKeyPress onKeyUp事件后,,不管什么小部件上的事件发生。
1
2
3
4
|
doKeyDown_:
function
() {
zk.keyCapture =
this
;
this
.$supers(
'doKeyDown_'
, arguments);
}
|
Notice that the key capture is reset automatically after processing onKeyUp_.注意,关键是复位后自动捕获onKeyUp_处理。
Offset lastPointer;
The last position that the mouse was clicked (including left and right clicks).最后的立场是,鼠标点击了(包括左和右点击)。
int loading;
The number of widget packages (i.e., JavaScript files) being loaded (and not yet complete). 小部件包的数量(即JavaScript文件)加载(和未完成)。When the JavaScript files of widgets are loading, you shall not create any widget. 当小部件的JavaScript文件装载,你不能创造任何部件。Rather, you can use相反,您可以使用zPkg#afterLoadzPkg #增加to execute the creation and other tasks after all required JavaScript files are loaded.执行创建和其他任务所需的所有JavaScript文件后被加载。
boolean mounting;
Whether ZK Client Engine has been mounting the peer widgets. ZK客户引擎是否已经安装对等小部件。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# afterMount
zk.Widget mouseCapture;
Used to specify a widget that shall receive the following the onMouseMove and onMouseUp events, no matter what widget the event occurs on.用于指定一个小部件,必得onMouseMove和onMouseUp事件后,不管什么小部件上的事件发生。
1
2
3
4
|
doMouseDown_:
function
() {
zk.mouseCapture =
this
;
this
.$supers(
'doMouseDown_'
, arguments);
}
|
Notice that the mouse capture is reset automatically after processing onMouseUp_.注意,鼠标捕获焦点是处理后onMouseUp_自动重启。
int procDelay;
The delay before showing the processing prompt (unit: milliseconds).之前的延迟显示处理提示(单位:毫秒)。
boolean processing;
Whether Client Engine is processing something, such as processing an AU response. 客户机引擎是否正在处理的东西,例如处理一个非洲联盟的响应。This flag is set when这个标志时设置#startProcessing# startProcessingis called, and cleaned when被称为呢,什么时候#endProcessing# endProcessingis called.被称为。
int tipDelay;
The delay before resending the AU request, i.e., assuming the last AU request fails (unit: milliseconds). 非盟的拖延之后,重新发送请求,即假设过去盟请求失败(单位:毫秒)。A negative value means not to resend at all.一个负值意味着不重发在所有。
int tipDelay;
The delay before showing a tooltip (unit: milliseconds).显示一个工具提示之前的延迟(单位:毫秒)。
boolean unloading;
Indicates whether the browser is unloading this document. 指示是否浏览器是卸载这个文档。Note: when注意:当#beforeUnload# beforeUnloadis called, this flag is not set yet.被调用时,这个标志不是集合吗。
String version;
The version of ZK, such as '5.0.0'ZK的版本,如“5.0.0”
Map $default(Map opts, Map defaultOpts);
Provides the default values for the specified options.提供默认值为指定的选项。
1
2
3
|
process:
function
(opts, defaultOptions) {
opts = zk.$
default
(opts, defaultOptions);
}
|
1
2
3
|
opts = zk.$
default
(opts, {timeout: 100, max:
true
});
//timeout and max are assigned to opts only if no such property found in opts
|
opts
- the options to be added the default options.——该选项来添加默认选项。 defaultOptions
- the default options——默认的选项 zk.Class $extends(zk.Class superclass, members, staticMembers);
zk.Class $extends(String superclassName, members, staticMembers);
Defines a class. 定义了一个类。It returns the class being defined.它返回的类定义。
1
2
3
4
5
6
7
8
9
|
zul.Label = zk.$extends(zk.Widget, {
_value:
''
,
getValue() {
return
this
._value;
},
setValue(value) {
this
._value = value;
}
});
|
The second format is used to declare a class that depends a class that might not be loaded yet. 第二个格式是用来定义一个类,取决于类,可能不被载入然而。It will cause the superclass to be loaded. 这将导���超类装入。However, you cannot access it until the superclass has been loaded.然而,您不能访问,直到超类已经被加载。
1
2
3
4
5
6
7
8
9
10
11
12
|
foo.Mine = zk.$extends(
'zul.inp.Textbox'
, {
});
new
foo.Mine();
//wrong! since zul.inp.Textbox might not be loaded yet
afterLoad(
function
() {
new
foo.Mine();});
//correct!
if
(foo.Mine.superclass) {
//test if it has been defined correctly (true if zul.inp.Textbox is loaded)
}
if
(zk.$import(
'zul.inp'
)) {
//another way to know
}
if
(zk.isLoaded(
'zul.inp'
)) {
//another way to know
}
|
Special Properties特殊属性
Here is a list of special properties that you can use in the members argument.以下列出的是特殊的属性,您可以使用在成员参数。
Name名称 Description描述
$define$定义 Used to specified a map of getters and setters. 用于指定一个getter和setter的地图。It is shortcut to invoke它是快捷键来调用define定义. 。For example,例如,
1234567891011
foo.Widget = zk.$extends(zk.Widget, {
_value:
''
,
$define: {
name:
null
,
value:
null
},
bind_:
function
() {
//
}
});
is equivalent to相当于
12345678910foo.Widget = zk.$extends(zk.Widget, {
_value:
''
,
bind_:
function
() {
//
}
});
zk.define(foo.Widget, {
name:
null
,
value:
null
});
is equivalent to相当于
1234567891011121314151617181920foo.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
() {
//
}
});
superclass
- the super class.——超类。 members
- the non-static members——非静态成员 staticMembers
- the static members. ——静态成员。Omitted if no static methods.省略了如果没有静态方法。 Object $import(String name, Function fn);
Imports a package or a class. 导入一个包或者一个类。It returns null if the package or class is not defined yet.它返回null如果包或类还没有定义。
1
2
3
4
|
var
foo = zk.$import(
'com.foo'
);
var
cool =
new
foo.Cool();
var
Cool = zk.$import(
'com.foo.Cooler'
);
var
cooler =
new
Cooler();
|
If you specify an additional function, then it 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.例如,下面创建一个Listbox窗口小部件装船后包。
1
|
zk.$import(
'zul.sel.Listbox'
,
function
(cls) {
new
cls();});
|
name
- The name of the package or the class.——软件包的名称或类。 fn
- The function to call after the class is loaded. ——要调用的函数的类被加载后。If specified, it assumes name is a class, and it will load the package of the class automatically.如果指定,它假定的名字是一个类,它将会被加载的类的包自动。 Object $package(String pkgnm);
Defines a package. 定义了一个包。It creates the package if not defined yet. 它创建包,如果还没有定义。It is similar to Java's package statement except it returns the package object.它类似于Java包的声明除了它返回包对象。
1
2
|
var
foo = zk.$package(
'com.foo'
);
foo.Cool = zk.
#$extends(zk.Object);
|
pkgnm
- The name of the package.——软件包的名称。 Object $void();
A does-nothing function, which is useful if you want to assume a does-nothing function, particular with一个does-nothing函数,它是有益的,如果你要承担一个does-nothing功能,尤其是与zEffectzEffect.
boolean afterLoad(Function func);
boolean afterLoad(String pkgnms, Function func);
The first format decalres a function that shall be executed after all requested packages are loaded (i.e.,第一种格式decalres一个函数,它将会被执行所有需要的包是加载后(即,#loading#加载is 0). If loading has been done, the function is executed immediately.是0)。如果加载已经完成,功能立即执行。
The second format declares a function that shall be executed only if the specified package(s) are loaded (and第二个格式声明一个函数,它应当只执行指定的包(s)装载(和#loading#加载is 0). Notice that it won't cause the package(s) to execute. 是0)。注意:这不会造���包(s)来执行。Rather, it defers the execution of the specified function until someone else loads the package (by use of相反,它无法执行指定的函数,直到别人加载包(通过使用#load#负载). )。It is useful if you want to这是有益的,如果你想customize JavaScript codes定制JavaScript代码.
To know whether all requested packages are loaded (i.e., ZK is not loading any package), you can check知道所有请求的包被加载(即ZK不是加载任何包),您可以检查#loading#加载if it is 0.如果它是0。
Notice that functions specified in the second format execute before those specified in the first format.注意,函数中指定的第二格式之前执行中所规定的第一种格式。
Example示例
1
2
3
|
zk.afterLoad(
'foo'
,
function
() {
new
foo.Foo();});
zk.afterLoad(
'foo1,foo2'
,
function
() {
new
foo1.Foo(foo2.Foo);});
zk.afterLoad(
function
() {});
|
void afterMount(Function fn);
Adds a function that will be executed after the mounting is done. 添加一个函数,将之后执行安装完成。By mounting we mean the creation of peer widgets. 通过挂载我们指的是创建小部件的同行。The function is executed immediately if the mounting has been done.这个函数是立即执行如果安装已经完成。
To know whether it is mounting, you can check知道究竟是安装,您可以检查#mounting#安装.
Notice that, unlike注意,不像#afterMount# afterMount, it never executes the function immediately.,它永远不会执行函数立即。
String comURI(String uri, Map opts);
Encodes and returns the URI to communicate with the server.URI编码,并返回与服务器通信。
1
|
document.createElement(
"script"
).src = zk.ajaxURI(
'/web/js/com/foo/mine.js'
,{au:
true
});
|
void beforeUnload([[JavaScript Function|Function] fn, Map opts);
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.删除函数,调用这个方法的参数指定删除选择。
1
|
zk.beforeUnload(fn, {remove:
true
});
|
Map copy(Object destination, Map source);
Copies a map of properties (or options) from one map to another.复制属性的一个map(或选项)从一个映射到另一个。
1
2
3
4
5
|
zk.copy(Array.prototoype, {
$add:
function
(o) {
this
.push(o);
}
});
|
destination
- the destination object to copy properties to.——目标对象复制属性。 source
- the properties to copy from——属性,以复制 void define(zk.Class klass, Map props);
Defines the setter and getter methods.定义setter和getter方法。
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例如,下面的代码片段
1
2
3
|
zk.define(zul.wgt.Button, {
disabled:
null
});
|
is equivalent to define three methods, isDisabled, getDisabled and setDisabled, as follows:相当于定义三个方法,isDisabled,getDisabled和setDisabled,如下:
1
2
3
4
5
6
7
8
9
10
|
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. 如果你想要做的事的值发生更改时在setter,您可以指定一个函数作为参数的值在道具。For example,例如,
1
2
3
4
5
|
zk.define(zul.wgt.Button, {
disabled:
function
() {
if
(
this
.desktop)
this
.rerender();
}
});
|
will cause the setter to be equivalent to将导致setter相当于吗
1
2
3
4
5
6
|
setDisabled:
function
(v, opts) {
this
._disabled = v;
if
(
this
._disabled !== v || (opts && 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,例如,
1
2
3
4
5
6
7
8
9
10
|
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将导致setter去相当于吗
1
2
3
4
5
6
7
|
setDisabled:
function
(v) {
v = v !=
null
&& v !=
false
;
this
._disabled = v;
if
(
this
._disabled !== v || (opts && 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. 注意,当这个函数(道具中指定)被调用,这些参数是相同的参数传递给setter(包括附加参数。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.用武力是真实的。
1
|
wgt.setSomething(somevalue, {force:
true
});
|
props
- a map of the properties whose getter and setter shall be defined. ——一个映射的属性的getter和setter应被定义。The name is the property name, such as href and width. 这个名字是属性名,如href和宽度。The value is either null or a function that will be invoked when the value is changed.这个值可以是null或一个函数,该函数将被调用的值发生更改时。 void depends(String dependentPkgnm, dependedPkgnm);
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.如果一个代码片断,既取决于包。
void disableESC();
Disable the default behavior of ESC. 禁用的默认行为,ESC。In other words, after called, the user cannot abort the loading from the server.换句话说,在调用时,用户不能中止从服务器加载。
void enableESC();
Enables the default behavior of ESC (i.e., stop loading from the server).支持ESC的默认行为(例如,停止从服务器加载)。
void endProcessing();
Clears a flag,扫清了国旗,#processing#处理, to indicate that it the processing has done. ,以表明它已经做了处理。It also removes a message, if any, that indicates "processing".它删除一条消息(如果有的话),表示“处理”。
1
2
3
|
zk.startProcessing(1000);
//do the lengthy operation
zk.endProcessing();
|
void error(String msg);
Display an error message to indicate an error.显示一条错误消息,指示一个错误。
1
|
zk.error(
'Oops! Something wrong:('
);
|
void errorDismiss();
Closes all error messages shown by关闭所有错误消息显示#error#错误.
1
|
zk.errorDismiss();
|
Object get(Object obj, String name);
Retrieves a value from the specified property.检索值从指定的属性。
For example,例如, zk.get(obj, "x")
: If getX or isX is defined in obj,:如果getX或isX定义在obj, obj.isX()
or或 obj.getX()
is returned. 返回。If not defined,如果没有定义, obj.x
is returned.返回。
1
|
zk.get(o,
'value'
);
|
obj
- The object to assign values to.——对象赋值到。 name
- The property name- name属性 String getHost(String pkg, boolean js);
Returns the URI of the server (so called host) for the specified package.返回的URI服务器(也称为主机)为指定的包。
ZK Client Engine loads the packages from the same server that returns the HTML page. ZK客户引擎加载软件包的同一台服务器返回的HTML页面。If a package might be loaded from a different server, you can invoke如果一个包可能是加载自不同的服务器,您可以调用#setHost# setHostto specify it and then指定它,然后#getHost# getHostwill return the correct URL for the specified package.将返回正确的URL指定的包。
boolean isLoaded(String pkgnm, boolean includeLoading);
Tests if a package is loaded (or being loaded).如果一个包加载测试(或被加载)。
boolean load(String pkgnms, Function func);
boolean load(String pkgnms, zk.Desktop dt, Function func);
Loads the specified package(s). 装载指定的包(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.然而,如果应用程序开发者想要访问的JavaScript的软件包,是不会加载,他将会调用这个方法。
The loading of a package is asynchronous, so you cannot create the widget immediately. 加载一个包是异步的,所以你不能立即创建小部件。Rather, use the third argument, func, or use相反,使用第三个参数,func,或使用#afterLoad#增加to execute.执行。
1
2
3
|
zk.load(
'zul.utl'
,
null
,
function
() {
new
zul.utl.Timer();
});
|
void log(vararg);
Logs an message for debugging purpose.日志消息用于调试目的。
1
2
|
zk.log(
'reach here'
);
zk.log('value is", value);
|
int parseInt(String value, int radix);
Parses a string to an integer.将一个字符串转换为整数。
It is the same as the built-in parseInt method except it handles NaN.它是一样的内置方法方法除了它处理南。
value
- the string to parse.——字符串解析。 radix
- represent the base of the number in the string. ——代表基地的连续的数字。10 is assumed if omitted.10是假定如果省略。 void set(Object obj, String name, Object value, Object extra);
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.被称为。
1
|
zk.set(o,
'value'
,
true
);
//set a single property
|
obj
- The object to assign values to.——对象赋值到。 name
- The property name- name属性 value
- The property value-属性值 extra
- 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)
. 。It is meaningless if there is no corresponding set method.它是没有意义的,如果没有相应的设置方法。 void startProcessing(int timeout);
Set a flag,设置一个标志,#processing#处理, to indicate that it starts an processing. ,表明它将提供一个处理。It also shows a message to indicate "processing" after the specified timeout.它还显示了一个消息来指出“处理”经过特定的超时。
1
2
3
|
zk.startProcessing(1000);
//do the lengthy operation
zk.endProcessing();
|
timeout
- the delay before showing a message to indicate "processing".之前——延迟显示一条消息来指出“处理”。 The message is shown immediately if omitted or 0.消息会立即显示如果省略或0。
void setHost(String hostURL, String updateURI, Array<String> packages);
Defines the URL of the host for serving the specified packages.定义了URL地址的主机服务指定的包。
<!-- end of the CONTAINER div --> <!-- Served in 0.195 secs. --><!-- Syntax -->
<script type="text/javascript"></script>
<!--<mce:script src="/skins/zk/syntaxhightlighter/shLegacy.js" mce_src="/skins/zk/syntaxhightlighter/shLegacy.js"></mce:script>-->
<script type="text/javascript"></script><script type="text/javascript"></script>
<!-- Google -->
<script type="text/javascript"></script><script type="text/javascript"></script><script type="text/javascript"></script>
<!-- Header -->
<script type="text/javascript"></script>