Jolene is a simple Java toolkit which provides a DOM (Document Object Model) of an HTML page to your java code. It can be used as replacement for JSP or Velocity for the view layer of a web application or it could be used as an html templating engine.
Jolene is not a template engine per se. It does not provide for special tags or variables like Velocity. What it does provide is a JavaScript like document object model for an HTML page inside Java.
Web designers don't need to concern themselves with JSP, custom taglibs or velocity macros. They can instead focus purely on web site design. Web developers don't need to concern themselves with layouts, styles, JavaScript and browser incompatibilities. They can instead focus purely on the web application functionality.
Jolene has no requirements for custom taglibs or programming languages imbedded in HTML pages. Straight HTML is all that's required from web designers. This means that there is no learning curve for web designers. Pages built with Dreamweaver (or even Frontpage) can be used as-is.
Iteration code in views is common with other frameworks. With Jolene - all code like this is done in Java code. Let's compare how you do this with velocity:
<TABLE> <TR> <TH width="30%">Name</TH> <TH width="30%">Code</TH> <TH width="30%">Description</TH> <TH width="10%"> </TD> </TR> #foreach ($item in $form.bean.list) <TR> <TD>$item.name</TD> <TD>$item.code</TD> <TD>$item.description</TD> <TD><A href="/editItem.do?$item.id">Edit</A></TD> </TR> #end </TABLE>
How would you do this with Jolene? In java code (like an action class) like this:
List data = getListOfBeanObjectsFromSomewhere(); Grid grid = document.forms(0).getGrid("grid1"); GridColumn col; List<GridColumn> header; List<String> fields; header = new ArrayList<GridColumn>(4); col = new GridColumn("Name", "30%"); header.add(col); col = new GridColumn("Code", "30%"); header.add(col); col = new GridColumn("Description", "30%"); header.add(col); col = new GridColumn("", "10%"); header.add(col); fields = new ArrayList<String>(4); fields.add("name"); fields.add("code"); fields.add("description"); fields.add("edit"); grid.bind(header, fields, data);
Notice that there is no loop here. You simply get a Grid object from your static HTML page (defined by a simple TABLE tag) and bind it to your data. You only need to define the columns, the field property names and the data itself.
The simplest way to get the document object is created by using new and passing in the file name of the HTLML file you want to open.
Document document = new Document("C:\projects\web\sample\hello.html");
From a servlet you could do this by using the URI instead.
String uri = request.getRequestURI(); Document documement = new Document(request.getServletContext().getRealPath(uri));
Note Jolene does this for you. See the section on the Struts plugin.
The document object contains objects for the header elements including title, and each form and all of it's objects. Supported form objects are Labels, Texts, TextAreas, Selects, Inputs (including checkboxes, radios, buttons), Buttons, Images and Data Grids.
Object properties can be modified in a variety of ways and can even be swapped with other Objects. Then you write the modified document to a file or to a web response.
Your html pages should have a head section, a body section and 1 or more forms.
Not really. Even large html documents parse in under a second. The usual parsing times from my tests are less than 100 milliseconds. Additionally in production use you should use document caching which will only parse the document once when initially requested.