Similar desktop user interface implementations for Java Web applications?


At work we're discussing upgrading our view layer for our web application. We're currently running an old and "modified" version of FreeMarker Classic, which is a pain to work with. One of our developers suggested using a Component UI style architecture similar to desktop style environments.

Essentially, this would mean that you would build custom HTML components as Java Classes that the controller would render into the Document view. This would completely take away the need to write HTML into a view layer. The Components would generate the view layer for you.

For instance, the following rendered HTML:

<h1>I am a title</h1>
<p>I am a paragraph.</p>

Would be generated by doing something like:

String titleString = "I am a title";
html.elements.Heading heading = new html.elements.Heading(Heading.H1, titleString);

String paraString = "I am a paragraph.";
html.elements.Paragraph paragraph = new html.elements.Paragraph(paraString);

PrintWriter somePrintWriter = new PrintWriter();
Document document = new Document();

The above code is just an example, don't critique the names or style, I just wrote it for a quick demonstration of what we may be trying to accomplish. I'm trying to determine if this has been done before in Java, and if so if there are any links I can be pointed to. I've been researching it as much as I can, but haven't found any implementations that completely remove the template layer (such as JSP or JSF).


There is a pure Java way where EVERYTHING is built using Java. Check it out here

UPDATE: I found even better one. Also pure Java.