State machines part six
David Geary presented an overview of JavaServer Faces at DJUG on Wednesday. I have to agree with his assessment that JavaServer Faces will be The Next Big Thing in java web app development. Interestingly, it looks like JSF will be notably similar to bOP.
JSF will be Java's answer to .NET and especially VisualStudio. Some of the big players in the Java world are going to put a lot of marketing muscle behind it. David mentioned that his book is going to be competing with a stunning number of JSF offerings. Many vendors want to sell you their IDEs. It seems the diversity in java's web framework ecosystem deters them from making web app magic happen in their tools. "Which framework should we support?" they ask. By blessing one framework the IDE vendors can focus their development resources on "The Standard". Just as the 1.4 logging APIs threaten to replace log4j, so will JSF threaten Struts, and all the rest of the java frameworks for that matter. Brace yourself for a tsunami of JSF hype.
In spite of the coming marketing storm, David showed off some good stuff. I welcome one change in particular. They borrow heavily from Struts, but have separated the concerns of site navigation from actions which change the state of the Model. Whereas, both of these things are handled with Action configurations in Struts, in JSF they are separated. In fact, the navigation configuration is yet another state transition table which will declare the flow through the application. The Actions get to focus just on changes in the state of the Model. This is one thing that I have missed from Turbine -- the navigation is separate from the actions which effect the model. That exact separation of concerns is also present in bOP.
David mentioned that there are places to declare the connection between a form and an object in the model. If he actually showed us that detail, I missed it. But he did mention repeatedly that JSF uses much more declarative programming. bivio brags about being declarative too.
What about the View?
JSF adds several stages in the life-cycle of a request. Some of those stages are specifically added to allow page widgets to trigger events. It allows you to "attach" server-side event listeners to those page widgets. They've done some pretty clever things to simulate a Swing-like event model while staying within the limits of HTTP. I'm sad to report that JSP still plays a central role. Taglibs provide some of the important hooks that help maintain the Swing-like look in the code. It looks like it will be hard to use other templating options with JSF -- the functionality provided by tag libraries for JSP would have to be replicated in Velocity or similar tools.
I'm not sure what to make of the move to Swingishness. See, I've drunk deeply from the templating kool-aid. I prefer Velocity to JSP for various reasons I won't go into here. When I wrote a little controller in perl for New Millennium, one of the key ingredients was HTML::Template -- it's not as cool as Velocity, but it let me separate the HTML from the controller.
Rob observes that templates make the same mistakes that old green screens did: mixing display codes with business logic and data. At first blush that sounds like JSP scriptlets. But I think Rob's assertion was more sweeping. Whether you're writing servlets with println()s or JSPs with scriptlets or concealing the scriptlets with tag libraries, there's a mixing "screen control characters" with logic and data. Velocity macros don't change that mix.
In bOP they use a Tk like language for defining the web pages. To the extent that Tk and Swing are similar, so is bOP's view language similar to JSF's stuff. Looking at David's examples for JSF helped me get my head around bOPs stuff a little more. bOP views assemble UI widgets into a hierarchy. I presume that bOP's facades are basically implementations of the language which render those widgets into HTML. I'm making educated guesses about what's going on behind the scenes. But I'm fascinated by the parallel development going on in JSF.
My feelings are still mixed. Rob's point about green screens is persuasive. But I'm just not quite ready to give up templating. Interestingly, bOP and JSF both seem to bring the web user interface back under the auspices of software development, perhaps taking it back from web designers. Maybe that's appropriate for web applications. It also seems like a natural progression for web apps. The GUI developers have worked through a lot of UI and usability issues in the past twenty years. Their toolkits look like Swing and Tk.