You might be wondering what this Flow thing is about - this page contains basic information about it.

History

The Cocoon flow layer was originally created by Ovidiu Predescu based on work done by Christopher Oliver, who implemented RhinoWithContinuations in the Rhino script engine.

Although Ovidiu is currently taking a break from Cocoon, several people have been continuing his work on code, samples and documentation.

Christopher and others have been working on the petstore example recently, a complete web application that demonstrates the Flow concepts (available with the Cocoon source code, see WhereToGet21Dev).

Basics

The flow layer of Cocoon acts as a very powerful yet simple to use controller in Model-View-Controller applications.

Here's a (slightly updated) example of a flowscript taken from Ovidiu's 2002 GetTogether Flow presentation (see link below)

var cart;
function checkout()
{
  sendPageAndWait("login.xml");
  var user = UserRegistry.getUser(cocoon.request.get("name"));
  sendPageAndWait("shippingAddress.xml");
  var address = cocoon.request.get("address");
  sendPageAndWait("creditCard.xml");
  var creditCard = cocoon.request.get("creditCard");
  sendPageAndWait("placeOrder.xml");
  EnterpriseSystem.placeOrder(cart);
  sendPage("orderPlaced.xml");
}

If you've been writing web applications with any other system you should see the huge advantage of Flow: the magic of continuations allows you to write the controller in linear fashion, with the Flow layer's sendPage method taking care of:

  • Sending the specified page to the web browser client
  • Saving the state of the Flow script
  • Getting input when the client response comes in (might be a few minutes later)
  • Transparently restarting the Flow script as if the user had instantly submitted the page

At this point we expect you to say something like WOW and go play with your first Flow application at GettingStartedWithFlow!

See also

TODO

Feel free to add any relevant information here! – BertrandDelacretaz

  • No labels