Jolene FAQ

What is Jolene?

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.

What's different about Jolene?

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.

What's so great about that?

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. 

How does Jolene differ from other view libraries?

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.

But HTML doesn't support dynamic grids for example - How would I do that?

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:

       <TH width="30%">Name</TH>
       <TH width="30%">Code</TH>
       <TH width="30%">Description</TH>
       <TH width="10%">&nbsp;</TD>

   #foreach ($item in $form.bean.list)

       <TD><A href="/$">Edit</A></TD>

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%");

col = new GridColumn("Code", "30%");

col = new GridColumn("Description", "30%");

col = new GridColumn("", "10%");

fields = new ArrayList<String>(4);

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.

How do I get the document object?

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.

What can I do with the document object?

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.

What are the minimum requirements for my html pages?

Your html pages should have a head section, a body section and 1 or more forms.

Isn't parsing slow?

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.