cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Oliver <>
Subject Woody + Flowscript
Date Sat, 05 Jul 2003 23:15:33 GMT
I just checked in a first try at adding Flowscript support to Woody. 
This consists of two JS classes and one function:

function woody(form_function, form_definition, form_attribute)

This is the entry point to the Woody Flowscript support.  You call the 
"woody" function from your sitemap to create a new form, for example:

   <map:match pattern="form1.flow">
           <map:call function="woody">
             <map:parameter name="function" value="form1"/>
             <map:parameter name="form-definition" value="forms/form1.xml"/>
             <map:parameter name="attribute-name" value="form1"/>

The "function" parameter specifies the name of a JS function that will 
provide the form's flow. The "form-definition" parameter specifies the 
location of the Woody form definition of the form. The "attribute-name" 
parameter specifies the name of a request attribute that will be used to 
store the form. The specified function will be called with one 
parameter, the newly created form.

class Form

The form itself will be an instance of the JS class Form. This class has 
methods to show the form and to access its underlying model, to get the 
id of the current submit button, and to destroy it:

function show([String] uri, [Function] validator);

This method repeatedly shows the form until validation is complete. If 
the validator function is supplied it will be called to do additional 
validation.  The function will be called with one argument containing a 
reference to the form.

function getSubmitId()
Returns the id of the selected Woody Button widget.

function finish();

Destroys this form and releases all of its resources.

function getModel()

Returns a JS wrapper of the Woody Form Widget.

class Widget

JS wrapper of Woody widgets. Provides access to the properties of the 
Woody form widgets. The widgets may be accessed by id. In addition, the 
"repeater" and "multivalue" widgets may be accessed as if they were JS 

I've added a complete sample of using Flowscript with Woody to the 
 Woody samples.

Here's the Flowscript source code for that sample:


function form1(form) {
    var model = form.getModel(); = "";
    model.somebool = true;
    model.account = 2;
    model.cowheight = 4;
    model.number1 = 1;
    model.number2 = 3;
    model.contacts[0].firstname = "Jules";
    model.contacts[1].firstname =  "Lucien";
    model.contacts[2].firstname = "Chris";
    model.drinks = ["Jupiler", "Coca Cola"];"form1-display-pipeline", function(form) {
        switch(form.getSubmitId()) {
        case "remove-selected-contacts":
                for (var i = model.contacts.length-1; i >= 0; i--) {
                    if (model.contacts[i].select) {
        case "add-contact":
            return true;
        return false;




View raw message