Monday, October 1, 2007

Rewriting the renderer to Java

Continuing my templating-experiment in Domino.

I'm doing this for two reasons, to brush up on my Java-skills (or lack thereof), and to make the templating syntax simpler (using the power of Regular Expressions).

Evaluating formulas are possible.

LotusScripts blocks not possible directly. You could write LS-statements to a field in a document, run a LS-agent that Executes the string, and prints the result in the same field. Open the document again in Java, and fill in the result, but I think that would be very hard to debug.

I hope to use this syntax (please give input if and why this is bad):
%moduleName% <- a module
$fieldName <- reference a field, wherever in the template
<@ .. @> <- formula block

Formula-blocks makes it possible to do stuff like:
<head><title>UFO Sightings</title></head>
    @If( @UserRoles = "[Editor]" ; "" ; @Return("<h1 style=\"color:red\">Access denied</h1>") );

    lup := @DbLookup( "" ; "" ; "(lupTopSecret)" ; "ufo" );

    "<h1>UFO Sightings</h1><ul>" +
    @Implode( "<li>" + lup + "</li>" ; "" ) + "</ul>"

This would be a standalone web-page, not a template referencing data from a stored document.

The above example is of course possible to do with a Form or a Page.

I'll see how long my interest in this experiment last. Hopefully I can make a demo that is hard to do with existing technology.

For instance,
<div id="nav">%menu%</div>
<div id="content">
<xmlTransform src=""
    xslt="" />



jasc said...

ARGH: "code" adjusted to get through... Just cut out the space beween < an $

Hm, why do you need RegEx? If you use something like < $ FIELD $ >, you just have to split the string two times:
first ("< $") to get all Fields and then split each entry by "$ >" the first part (which would be the fieldname) and the rest.

Tommy Valand said...

Splitting combined with Like in LS would probably work just as well, but RegEx wasn't the biggest reason I wanted to switch.

Java has more advanced web classes than LS has, so this is a good opportunity to learn some Java.