ztemplates has built in support for writing AJAX forms with server side validation and value updates.
ztemplates comes with enhanced support for JavaScript frameworks like The Yahoo! User Interface Library (YUI)
. See downloads for examples. Any other JavaScript framework can be integrated in a similar way, see the Google AJAX Search example.
The deployment is extremely simple:
No need to worry which javascript to include, in which order etc. All needed resources are placed in your page by ztemplates.
The support for JavaScript consists mainly of the @ZScript annotation that allows to declare the css and javascript needed by a template.
ztemplates collects all scripts used for a certain page, computes a topological sort on the script dependencies and exposes only the scripts needed as a ${zscript} variable to the template so you can place it into the head section of your html page. ztemplates.css is also included by default in the ${zscript} output, so there is no need to include it by yourself anymore.
To optimize performance, all javascript that comes from your webapp is automatically merged into one javascript file then minified with JSMin and gzipped.
If the dependency graph contains cycles it will display a warning on the console and remove edges to resolve cycles.
For optimal performance computation of zscript is turned off by default, as it is needed only for the template that generates the html head section. Turn it on by using @ZRenderer(..., zscript=true).
When using zscript=true, $renderService will not be exposed to the context. That is because ztemplates needs to collect all annotations from all render-pojos used to create the view, but $renderService.render() from the template happens after zscript has been exposed, so it would miss those script imports.