» Jease » Blog » Documentation

Want to contribute?


Do you want to contribute to Jease? Writing documentation is a good place to get started and will help to get people becoming more familiar with Jease. Any contribution is appreciated.


Jease is easily extensible directly through the CMS by running scripts which can do all kinds of dynamic stuff. Simply add an Script-Object to Jease and give it an id with a proper extension denoting the kind of script contained in the object.


Out of the box you can use JavaServerPages (with extension ".jsp"). Just create a Script object, name it News.jsp and enter the following code as an example which creates a listing of all published news:

<%@page import="jease.cms.domain.*,jease.site.*"%>
<% for(News news : Navigations.getSiteNews()) { %>
 <h2><%=news.getTitle()%> (<%= String.format("%tF", news.getDate())%>)</h2>
   <br />
   <a href="<%=news.getPath()%>?print">Read more...</a>
<% } %>

Another example is to create a sitemap as XML-file for submission to your search engine of choice. Create this script with the "Forward"-attribute checked, so the content is returned directly (without being rendered in the page layout).

<?xml version="1.0" encoding="UTF-8"?>
<%@page import="jfix.servlet.*,jease.cms.domain.*,jease.cmf.service.*" 
        contentType="text/xml; charset=utf-8" %>
 xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
  String domain = (request.isSecure() ? "https://" : "http://") +  Servlets.getHost(request) + request.getContextPath();
  for(Content content : Nodes.getRoot().getDescendants(Content.class)) { 
      if(content.isVisible()) {              
  <loc><%=domain %><%=content.getPath()%></loc>
<% } %>
<% } %>


Another option which is provided out of the box are dynamic servlets, which don't need to be configured in your web.xml. Just create a Script-Object with the extension ".java" and put the code of your servlet into it. The rest is handled by a Java-Compiler which compiles and runs the servlet automatically.

To test it out, just add a Script-Object with id=HelloServlet.java and put the following code into it:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloServlet extends HttpServlet {
  public void doGet (HttpServletRequest request,
                     HttpServletResponse response)
    throws ServletException, IOException {
    PrintWriter out = response.getWriter();
    out.print("Hello " + request.getParameter("name"));

Now you can call the servlet and feed it via a request parameter (e.g. http://localhost:8080/HelloServlet.java?name=Jease).

ZUL Markup

Jease allows also the seamless integration of ZUML - the ZK based markup language (use ".zul" as extension). Below is an example for a simple contact form. Just create a Script with id=contact.zul and copy the code below into it.

You can also have a look at more [./~/demo/zul ZUL showcases].

<vlayout width="100%"> 
  <textbox id="name" hflex="1" constraint="no empty"/> 
  <textbox id="email" hflex="1" constraint="/.+@.+\.[a-z]+/: No valid address" />
  <textbox id="message" hflex="1" rows="10" constraint="no empty" /> 
  <button label="Send Message"> 
    <attribute name="onClick"><![CDATA[ 
      if(name.isValid() && email.isValid() && message.isValid()) { 
          "Message from " + name.value + " <" + email.value + ">",
        name.rawValue = email.rawValue = message.rawValue = null;
        Messagebox.show("We have received your message.", "Thank you!",
                        Messagebox.OK, Messagebox.INFORMATION);
      } else {
        Messagebox.show("All fields are required!", "Error", 
                        Messagebox.OK, Messagebox.ERROR);

Adding other scripting languages

If you want to add support for another scripting language (e.g. Groovy, Velocity, Freemarker), you'll have to configure a servlet which handles the scripting language.

Here's an exmample for adding Groovy support to Jease:

  • Download Groovy distribution and copy "groovy/embeddable/groovy-all.jar" to Jease/WEB-INF/lib.
  • Edit Jease/WEB-INF/web.xml to add support for the GroovyTemplateServlet:

Now you can use the content-type "Script" to execute GroovyTemplates. All you have to do is to specify the appropriate extension (.groovy) as id for the Script.

Example "Sitemap.groovy"

<% import jease.cmf.service.*; %>
 Nodes.root.descendants.findAll{it.visible}.each {
  parents = it.parents.length;
  style = parents == 1 ? "font-weight: bold;" : 
                "margin-left: " + parents + "em;";
  <a href="<%= it.path %>" style="<%= style %>">
   <%= it.title %>
  <br />
<% } %>

Last modified on 2011-05-26 by Maik Jablonski