ztemplates
ztemplates is a small and easy to learn open source action web framework based on Java jdk1.5 or later.
ztemplates integrates well with Apache Velocity
, JSP, FreeMarker
, AJAX, Yahoo User Interface (YUI)
, Google APIs
and can easily be extended to your preferred rendering technology.
Why another framework
- based on annotations and autodiscovery
- ztemplates is statefree
- it places no constraints on the url format. If you imagine the urls as a tree, in ztemplates not only the leaves carry information but also the path from the root of the tree to the leaf. You can define variables in the url and map them to pojo properties. The same is true for form parameters.
- ztemplates has annotation based AJAX support. Need not worry which css, javascript to import when using provided components.
- JavaScript is automatically merged at runtime into one file, minified with JSMin and gzipped.
- ztemplates is robust. It's hard to break urls by refactoring, moving or renaming files.
- ztemplates is a filter. It passes through all urls it cannot match. So you can transparently add it to or remove it from your existing webapp.
- Most frameworks have a steep learning curve and lots of xml files scattered around in different places. In contrast, because of the autodiscovery feature, ztemplates needs no configuration, just declare a filter in your web.xml and map it to '/*'. New modules are installed by adding a jar to WEB-INF/lib. All files are kept in one place.
In a nutshell
- ztemplates is built around urls: /index
- urls can contain url-variables: /blog/${author}/${date}/edit
- annotate a action-pojo with @ZMatch("yourUrlPattern"): @ZMatch("/index")
- url-variables are assigned to action-pojo properties
- urls can be nested(included) in each other with url-references /page/#{menu}/#{content}.
- the nesting supports inheritance (polymorphism)
- the url defines a sequence of callbacks.
- the callbacks contain the application logic and create the view (render-pojos).
Unlike other frameworks, where the url is used to instantiate one action handler, in ztemplates the url is used to select a sequence of action-handlers from a hierarchy of actionhandlers, defined by the url-references.
- define the view data in render-pojos
- define the view in a template file (JSP, Velocity,...)
- annotate the pojo with @ZRenderer to link the pojo to the template
- annotate the pojo-properties with @ZExpose to expose them to the template
- include views by exposing render-pojos and render them with @ZExpose(render=true)
- style the view with css by placing a css fragment next to the pojo. ztemplates will aggregate all fragments in the classpath to one style sheet available as ztemplates.css
- include JavaScript in the output by declaring needed javascript/css files with @ZScript
Examples, Tutorials
- Take a look at the short examples and tutorials that show step by step how to create your first ztemplates applications. You will touch the main concepts of ztemplates.
- If you like to dive in, look at the Url Reference Tutorial
- For latest developments go to the changelog
Concepts
updated for version 0.9.9.2