Your votes power DZone. Login and vote now.
By puredanger
via rethrick.wordpress.com
Published: Jul 13 2008 / 19:56
We’ve all been there: fired up the next set of changes in a webapp and navigated through a complex flow, entering fake data for the n-th time only to find a massive exception on the page we’ve been expectantly working on, due to a simple typo.
SaveShareSend
Tags: frameworks, java
Comments
zynasis replied ago:
Couldn't agree more.
killerweb replied ago:
It's a catch 22, like with DLs. If the compiler of the template needs to know what the object structure is at compile time, either give the compiler all that information upfront, that adds lots of work to creating dynamic templates. And option 2, flight-check at runtime and throw warnings up when running, which creates performance hiccups. No one solution fits everyone, developers that want to build fast and also prototype ideas will take the complete dynamic route, other developers will take the "give it more information upfront" and let the compiler speak approach. Good article, but I think saying Web frameworks are broken for this reason is a little much. But broken because of their complexity, maybe ;)
jmarranz replied ago:
I can’t agree more too.
This is the typical problem of “executable views” or “pull views” (the view pulls data), in the old JSP approach Java code was hard coded and the compiler was very useful to detect coding bugs. Now most of the templating engines interpret the view (the view logic uses interpreted languages) and there is no way to detect errors in a compiler phase.
The alternative is using non-executable views or web frameworks with “push views” (the application pushes any data to the view). Frameworks with “push views” reduce the view logic in the view, in some way the view rendering is “driven” by Java code, one immediate benefit is a cleaner view/view logic separation.
Terence Parr talks about this:
http://www.cs.usfca.edu/~parrt/papers/mvc.templates.pdf
There are no very much examples of web frameworks with push views (pull view approach is dominant), some examples:
- StringTemplate: a proof of concept of Terence Parr ideas.
http://www.stringtemplate.org
- GWT : this is an extreme example because there is no template, view is built programmatically.
http://code.google.com/webtoolkit/
- Wicket: the template is almost pure HTML, most of the logic is defined in Java
http://wicket.apache.org
- ItsNat: my preferred, because I’m the author :) In ItsNat the view logic is pure Java using W3C DOM Java APIs and the templates is absolute pure HTML (or SVG).
http://www.itsnat.org
sproketboy replied ago:
Yup or you can look at Jolene.
http://jolene.sourceforge.net/
It's still in it's early stages. Jolene requires no custom tags or attributes of any kind. Plain old HTML pages are used as-is. Jolene parses and returns a DOM to Java so all the expression type coding is done away with. You can everything in Java itself and get all the nice type safety.
Currently it's still in Alpha because I'm re-arranging the code and building samples apps but I've been using it for a long time. It works with files, servlets or struts 1.2/1.3. It could be used with any framework which uses JSP or Velocity.
Voters For This Link (23)
Voters Against This Link (3)