zscript"
m |
|||
Line 3: | Line 3: | ||
__TOC__ | __TOC__ | ||
− | + | '''Syntax:''' | |
− | <zscript [language="Java|JavaScript|Ruby|Groovy"]>''Scripting codes''</zscript> | + | <zscript [language="'''Java'''|JavaScript|Ruby|Groovy"]>''Scripting codes''</zscript> |
− | <zscript src="'' | + | <zscript src="''a_uri''" [language="'''Java'''|JavaScript|Ruby|Groovy"]/> |
− | |||
It defines a piece of scripting codes that will be interpreted when the page is evaluated. The language of the scripting codes is, by default, Java. You can select a different language by use the <tt>language</tt> attribute<ref>Furthermore, you can use the page directive to change the default scripting language other than Java.</ref>. | It defines a piece of scripting codes that will be interpreted when the page is evaluated. The language of the scripting codes is, by default, Java. You can select a different language by use the <tt>language</tt> attribute<ref>Furthermore, you can use the page directive to change the default scripting language other than Java.</ref>. | ||
Line 27: | Line 26: | ||
== src == | == src == | ||
− | + | [Optional][Default: ''none''] | |
− | [Optional][Default: ''none''] | ||
− | |||
Specifies the URI of the file containing the scripting codes. If specified, the scripting codes will be loaded as if they are embedded directly. | Specifies the URI of the file containing the scripting codes. If specified, the scripting codes will be loaded as if they are embedded directly. | ||
Line 53: | Line 50: | ||
== language == | == language == | ||
− | + | [Optional][Default: the page's default scripting language][Allowed Values: Java | JavaScript | Ruby | Groovy] | |
− | [Optional][Default: the page's default scripting language][Allowed Values: Java | JavaScript | Ruby | Groovy] | ||
− | |||
It specifies the scripting language which the scripting codes are written in. | It specifies the scripting language which the scripting codes are written in. | ||
Line 61: | Line 56: | ||
== deferred == | == deferred == | ||
− | + | [Optional][Default: false] | |
− | [Optional][Default: false] | ||
− | |||
Specifies whether to defer the evaluation of this element until the first non-deferred <tt>zscript</tt> codes of the same language has to be evaluated. It is used to defer the loading of the interpreter and then speed up the loading of a ZUML page. For example, if all <tt>zscript</tt> elements are deferred, they are evaluated only when the first event listened by a handler implemented in <tt>zscript</tt> is received. | Specifies whether to defer the evaluation of this element until the first non-deferred <tt>zscript</tt> codes of the same language has to be evaluated. It is used to defer the loading of the interpreter and then speed up the loading of a ZUML page. For example, if all <tt>zscript</tt> elements are deferred, they are evaluated only when the first event listened by a handler implemented in <tt>zscript</tt> is received. | ||
Line 71: | Line 64: | ||
== if == | == if == | ||
− | + | [Optional][Default: true] | |
− | [Optional][Default: true] | ||
− | |||
Specifies the condition to evaluate this element. This element is ignored if the value specified to this attribute is evaluated to false. | Specifies the condition to evaluate this element. This element is ignored if the value specified to this attribute is evaluated to false. | ||
Line 79: | Line 70: | ||
== unless == | == unless == | ||
− | + | [Optional][Default: false] | |
− | [Optional][Default: false] | ||
− | |||
Revision as of 10:32, 18 November 2010
Syntax:
<zscript [language="Java|JavaScript|Ruby|Groovy"]>Scripting codes</zscript> <zscript src="a_uri" [language="Java|JavaScript|Ruby|Groovy"]/>
It defines a piece of scripting codes that will be interpreted when the page is evaluated. The language of the scripting codes is, by default, Java. You can select a different language by use the language attribute[1].
The zscript element has two formats as shown above. The first format is used to embed the scripting codes directly in the page. The second format is used to reference an external file that contains the scripting codes.
<zscript>
alert("Hi");
</zscript>
<zscript src="/codes/my.bs"/>
Like other ZK elements, it is not a component but a special XML element.
Notes
- ↑ Furthermore, you can use the page directive to change the default scripting language other than Java.
src
[Optional][Default: none]
Specifies the URI of the file containing the scripting codes. If specified, the scripting codes will be loaded as if they are embedded directly.
Note: the file shall contain the source codes in the selected scripting language. The encoding must be UTF-8. Don't specify a class file (aka. byte codes).
Like other URL and URI, it has several characteristics as follows.
- It is relative to the servlet context path (aka., the getContextPath method from the javax.servlet.http.HttpServletRequest interface). In other words, ZK will prefix it with the servlet context automatically.
- It resolves "~" to other Web application (aka., different ServletContext). Notice that Web server administrator might disable Web applications from peeking other's content[1].
- It accepts "*" for loading browser and Locale dependent style sheet.
The algorithm to resolve "*" is as follows.
- If there is one "*" is specified in an URL or URI such as /my*.css, then "*" will be replaced with a proper Locale depending on the preferences of user's browser.For example, user's preferences is de_DE, then ZK searches /my_de_DE.css, /my_de.css, and /my.css one-by-one from your Web site, until any of them is found. If none of them is found, /my.css is still used.
- If two or more "*" are specified in an URL or URI such as "/my*/lang*.css", then the first "*" will be replaced with "ie" for Internet Explorer and "moz" for other browsers[2]. If the last "*" will be replaced with a proper Locale as described above.
- All other "*" are ignored.
Notes
language
[Optional][Default: the page's default scripting language][Allowed Values: Java | JavaScript | Ruby | Groovy]
It specifies the scripting language which the scripting codes are written in.
deferred
[Optional][Default: false]
Specifies whether to defer the evaluation of this element until the first non-deferred zscript codes of the same language has to be evaluated. It is used to defer the loading of the interpreter and then speed up the loading of a ZUML page. For example, if all zscript elements are deferred, they are evaluated only when the first event listened by a handler implemented in zscript is received.
Refer to the How to Defer the Evaluation section in the Developer's Guide.
if
[Optional][Default: true]
Specifies the condition to evaluate this element. This element is ignored if the value specified to this attribute is evaluated to false.
unless
[Optional][Default: false]
Specifies the condition not to evaluate this element. This element is ignored if the value specified to this attribute is evaluated to true.
Version History
Version | Date | Content |
---|---|---|