Blogging Roller

Dave Johnson on open web technologies, social software and software development


Why am I doing this Control Flow stuff?

Maybe I should explain why I'm wasting valuable late-night Roller development time with this continuations stuff. I'm experimenting with Control Flow because I'm frustrated with Struts (and other web-MVC frameworks) lack of support for building complex web applications where user-interactions extend over multiple pages. I'm tired of little ad-hoc tricks like session attibute here, request parameter there, breadcrumb stacks, and hidden fields that developers must remember to place on each page. There has got to be a better way and a continuations-based approach seems like it may be that better way. Ken McLeod explains the appeal of a continuations-based approach quite nicely:

<a href= "http://bitsko.slc.ut.us/blog/prevalent-continuations.html">Ken MacLeod: Continuation-based web frameworks let you write complex, modeless, interactive web applications in a top-down, linear fashion as simple as writing command-line based applications that prompt for input.

That sounds great, but I don't really want to switch to a new framework to take advantage of a continuations approach. I've got an investment in Struts and JSP and what I would really like to do is to learn from the continuations-based frameworks and, if possible, apply that knowledge to my existing webapps. What I would like to learn is:

  • Should you write entire webapps as "top-down, linear" programs, or should you just use a continuations-based approach for portions of webapps, perhaps only the parts that involve multi-page user-interactions. Charles Miller points out an important reason why you might not want to take the entire-app approach: webapps must be able to provide meaningful and bookmarkable URLs (cool URLs) and some continuations-based frameworks make this difficult.
  • Does it make sense to use Control Flow in the context of a plain-old web-MVC based framework (e.g. Struts, Webwork). How would you do this? Does the Control Flow script kick in before an Action is run, as part of the Front Controller, or after the Action completes?
  • Does it make sense to use Control Flow in the context of a next-generation web-MVC based framework with events and server-side UI components (e.g. JSF, Tapestry)? How would you do this? How should the Control Flow engine fit into the component request/response lifecycle?

There you have it. Please, leave a comment if you have any insight into any of the above questions.

Tags: Java

Prevalent Continuations

by Ken MacLeod
Tags: Links

Control Flow is free!

After some late night hacking sessions, I've been able to rip Cocoon's Control Flow component free of Cocoon. I removed all dependencies on Cocoon and Avalon and pared my standalone version of Control Flow down to only 14 classes and a couple of JavaScript functions.

Below is the simple JavaScript code that I'm using to test Control Flow. This code will eventually run on the server side and will send a web page to the user when it needs input. The forwardAndWait() method puts the name of the page or Struts forward into a 'tray' object and suspends execution. Eventually, it will suspend execution of the script, call a JSP page or a Struts forward, and wait for the response to go out and the request to come back in.

function test(tray) 
{
   log.info("I called my script!");
   forwardAndWait(tray, "page1.html");
    
   log.info("I'm back in the script");
   forwardAndWait(tray, "page2.html");

   log.info("all done!");
}

Below is the code I'm using to run and test this script. Step #1 sets up the 'tray' that I use to get the forward name and continuation id out of the JavaScript world. I introduced the tray concept, and I don't really like it but I'm not sure how else to get the values I need out of JavaScript. Step #2 and #4 are the interesting bits. Step #2 calls the JavaScript method, which executes and then suspends the script execution inside the 1st JavaScript forwardAndWait() call. Step #4 resumes execution of the script using the continuation id found in the tray.

JavaScriptInterpreter interp = new JavaScriptInterpreter();      
interp.initialize();     
interp.register("C:\\allfiles\\scratch\\StrutsFlow\\src\\flow\\system.js");
interp.register("C:\\allfiles\\scratch\\StrutsFlow\\tests\\flow\\test.js");
      
Scriptable s = interp.enterContext();
      
// 1. setup tray param to hold forward
List params = new LinkedList();
List tray = new LinkedList();
params.add(new Argument("tray", tray));

// 2. call function
interp.callFunction("test", params);
     
// 3. funcion suspended, now tray should contain forward name
assertTrue(((String)tray.get(0)).equals("page1.html"));
// and the continuation id
String kontid = (String)tray.get(1);
      
// 4. resume exection of script using that contination id
interp.handleContinuation(kontid, new LinkedList());
      
// 5. function suspeded again, now tray should contain second forward name
assertTrue(((String)tray.get(0)).equals("page2.html"));
      
// 6. resume function, so it may complete execution
kontid = (String)tray.get(1);
interp.handleContinuation(kontid, new LinkedList());
      
interp.exitContext(s);

And below is the debug output from running the test code above.

JS-INFO: I called my script!
JS-DEBUG: WK: Just Created New Continuation 4d281a763e7c1b3f5a7b4e244b2e224729112160
JS-INFO: I'm back in the script
JS-DEBUG: WK: Just Created New Continuation 877d715e813c5a7c4e7f1a56612826332f528167
JS-INFO: all done!

Next, I'll try to implement the same NumberGuess example from the Control Flow tutorial, but with no Cocoon - only JSP and Servlets.

Tags: Java

TriJUG tonight: David Geary talks JSF.

Poised to become the preeminent--not to mention standard--Java Web application framework, JavaServer Faces is the next big thing for server-side Java. Come find out what all the fuss is about in this cutting-edge session given by a member of the JSF Expert Group. Learn what JSF has to offer, how it compares to Struts, and how you can start using it today.
For more info and directions: TriJUG JSF Talk Announcement
Tags: Java

Struts Flow

I'm having too much fun hacking apart Cocoon's uber cool Control Flow component to even think about blogging right now. I want to experiment with Control Flow in a simple Struts-based app, but at this point I'm still trying to get my standalone verson of Control Flow working in a simple unit test. If and when I come up for air, I promise a full report.

Tags: Java

RSS Quiz

Tags: Links

Thou shalt separate business logic from display.

Terence Parr, Enforcing Model-View Separation in Template Engines (PDF): Without exception, programmers espouse separation of logic and display as an ideal principle. In, practice, however, programmers and engine producers are loath to enforce separation, fearing loss of power resulting in a crucial page that they cannot generate while satisfying the principle.
Excellent paper, found via Bill de hOra - a good read for any web developer.
Tags: Java

1st Struts-Faces nightly

found via Andrew Kuzmin's weblog
Tags: Links

Roller 0.9.8.2 out shortly.

Since the Roller 0.9.8.1 release, I have made a number of fixes in the stable ROLLER_098_BRANCH to support JRoller including: additional database indexes for performance, referential integrity fixes, and RSS encoding fixes. Rick Ross will be happy to hear that, with the latest round of fixes, I have finally killed the dayhits rollover bug. I have deployed Roller 0.9.8.2 to JRoller and if all goes well over the next 24 hours, I'll release it on SourceForge.

In other news: Roller 0.9.9 is progressing nicely and is probably less than a month off. See also: <a href= "http://opensource.atlassian.com/projects/roller/BrowseProject.jspa?id=10000&report=roadmap"> Roller's JIRA roadmap.

Tags: Roller

Thanks Jaap!

Shortly after I internationalized the Roller JSP pages, Jaap van der Molen sent me a complete Dutch translation and an offer to update it as needed. Thanks Jaap!

Tags: Roller

Hard to imagine a worse model for UI development than HTTP.

Abstract: Using Smalltalk to Redefine Web Development It would be hard to imagine a worse model for user interface development than HTTP. Would you use a GUI framework where every event from every widget in your application was handed to you at once, periodically, as a large hashtable full of strings? Where every time a single piece of data changed you had to regenerate a textual description of the entire interface? Where the event-based architecture was so strict that you couldn't ever, under any circumstances, open a modal dialog box and wait for it to return an answer?
[...]
For all its limitations, the web is fast becoming the most important deployment platform for many classes of application. The Java, Perl, PHP, and .NET worlds, to name a few, are pursuing it agressively. Many of us are going to have to play their game -- but we don't have to play by their rules.
That's part of the abstract for a talk on Seaside, a Smalltalk and continuation based web application development framework (via James Robertson's blog). Seaside is one of many continuation based frameworks. The more I read about these frameworks the more I become convinced that the holy grail of web development lies in the castle of continuations. I've previously mentioned the two Java entries in the quest for the grail: RIFE and Cocoon ControlFlow. I need to find some time to investigate these frameworks and figure out how they relate, if at all, to JSP and JSF.
Tags: Java

Deadlines suck.

That's all.

Tags: General

7% of adults blogging?

Pew Internet Project Report
Tags: Links

Another prediction.

I'm going to go out on a limb and make another prediction: Roller 0.9.9 will ship with a kick-ass (forgive me, I'm from North Carolina) Atom implementation that is not named after a washed-up SNL cast-off. Zing!

Tags: Roller

Clements thinks we are serious.

<a href= "http://staff.newtelligence.net/clemensv/PermaLink.aspx?guid=8fe41294-a988-4c73-948a-1bfab622fcce"> Clemens thinks we are all serious about this open source software thing. Ssssh! Don't tell him we are just doing it to cut off Microsoft's air supply. Oh, and by the way, as soon as Microsoft is out of business, one Roller license will cost you about $10,000/server.

Tags: General

Today we learn

- I'm guessing - about Mark's new job - a closely guarded secret as Mark put it on IRC. My prediction is that Mark will be working for OSAF on Chandler. Update: I was totally wrong. Congratulations to Mark on his new job at IBM.

Tags: Blogging

« Previous page of month (Mar 2004) | Main | Next month (Apr 2004) »