views:

356

answers:

6

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();
document.addElement(heading);
document.addElement(paragraph);
document.compose(somePrintWriter);

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).

Thanks!

A: 

How about GWT?

jdigital
This seems more geared towards Ajax that we are looking for, unless I'm completely missing something. It is definitely along the same lines though.
localshred
A: 

Echo2/Echo3 might be useful.

Echo is a platform for building web-based applications that approach the capabilities of rich clients. The applications are developed using a component-oriented and event-driven API, eliminating the need to deal with the "page-based" nature of browsers. To the developer, Echo works just like a user interface toolkit.

instanceofTom
This looks like the closest thing to what we are trying to accomplish. The only thing is that it is an entire framework, which we wouldn't have the ability to implement. We're looking strictly for the view architecture.
localshred
A: 

I used GWT-Ext to create a desktop-feel for a Java-based web app. It was very well received and feels very much like you are not within a web browser at all.

JoshJordan
I'll check this out, but I'm not sure we're looking for a SproutCore type implementation, where the app looks like a desktop app. We just want the component UI style techniques.
localshred
A: 

Click is pretty close, to what you are describing. It does use Velocity, but if you take a look at the Advanced Forms example, the template was very basic.

wingS is another one that looks to be close to what you want. It is supposed to be Swing like.

Philip T.
+2  A: 

There is a pure Java way where EVERYTHING is built using Java. Check it out here http://www.zkoss.org/

UPDATE: I found even better one. Also pure Java. http://vaadin.com/home

eugener
A: 

Use Apache Click and Vaadin. Here detailed comparison

http://stackoverflow.com/questions/2358371/vaadin-vs-apache-click-which-one-to-choose-for-my-webapp-development

PS: I use Apache Click with freemarker. Click supports Velocity/Freemarker/JSP. Velocity engine is just default one.

Andrew Fink