JavaScript Packaging"
m |
m |
||
Line 4: | Line 4: | ||
If you'd like to customize the client-side behavior<ref>It is optional and you could refer to [[ZK Developer's Reference/UI Composing/Client-side UI Composing|Client-side UI Composing]] and [[ZK Developer's Reference/Event Handling/Client-side Event Listening|Client-side Event Listening]] for more information.</ref>, it will end up with some JavaScript code. The can be packaged in several ways depending on the size and re-usability. | If you'd like to customize the client-side behavior<ref>It is optional and you could refer to [[ZK Developer's Reference/UI Composing/Client-side UI Composing|Client-side UI Composing]] and [[ZK Developer's Reference/Event Handling/Client-side Event Listening|Client-side Event Listening]] for more information.</ref>, it will end up with some JavaScript code. The can be packaged in several ways depending on the size and re-usability. | ||
+ | |||
+ | <blockquote> | ||
+ | ---- | ||
+ | <references/> | ||
+ | </blockquote> | ||
=Embed the JavaScript Code Directly= | =Embed the JavaScript Code Directly= | ||
Line 40: | Line 45: | ||
</source> | </source> | ||
− | + | =Make it a WPD file for more control= | |
− | + | Technically, you could do whatever you want with a JavaScript file. However, if you prefer to make it a JavaScript package, such that they will be loaded automatically when required, you could package them as [[ZK Developer's Reference/Widget Package Descriptor|a WPD file]]. | |
− | |||
− | |||
=Version History= | =Version History= |
Revision as of 10:09, 30 November 2010
If you'd like to customize the client-side behavior[1], it will end up with some JavaScript code. The can be packaged in several ways depending on the size and re-usability.
- ↑ It is optional and you could refer to Client-side UI Composing and Client-side Event Listening for more information.
Embed the JavaScript Code Directly
Use the script directive to embed the code directly. For example,
<!-- foo.zul -->
<?script type="text/javascript" content="jq.IE6_ALPHAFIX='.png';"?>
Alternatively, you could use the script component to embed the code.
Put in a Separate File and Reference it in the ZUML page
If there are a lot of JavaScript code, it is better to package them in a separate file, and then use the script directive to reference the file in every ZUML page that requires it.
<!-- foo.zul -->
<?script type="text/javascript" src="/myjs/foo.js"?>
Put in a Separate File and Reference it in Language Addon
If the JavaScript code will be used in every ZUML pages, it is better to package them in a separate file, and then make it part of the the language definition. To make it part of the language definition, you could specify the following content in the language addon, say, WEB-INF/lang-addon.xml:
<language-addon>
<javascript src="/myjs/foo.js"/>
</language-addon>
Then, you could specify the language addon in WEB-INF/zk.xml:
<language-config>
<addon-uri>/WEB-INF/lang-addon.xml</addon-uri>
</language-config>
Make it a WPD file for more control
Technically, you could do whatever you want with a JavaScript file. However, if you prefer to make it a JavaScript package, such that they will be loaded automatically when required, you could package them as a WPD file.
Version History
Version | Date | Content |
---|---|---|