cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Portier <...@outerthought.org>
Subject Re: Woody + Flowscript
Date Sun, 06 Jul 2003 10:59:56 GMT
Wow,

this was on my todo-list for some weeks from now

will surely have a look at it
(hoping even to be able to make time ahead of my schedule for this)

many thx,
-marc=

Christopher Oliver wrote:
> 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"/>
>           </map:call>
>     </map:match>
> 
> 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 
> arrays.
> 
> I've added a complete sample of using Flowscript with Woody to the Woody 
> samples.
> 
> Here's the Flowscript source code for that sample:
> 
> cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/woody.js");
> 
> function form1(form) {
>    var model = form.getModel();
>    model.email = "bar@www.foo.com";
>    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"];
>      form.show("form1-display-pipeline", function(form) {
>        print("submitId="+form.getSubmitId());
>        switch(form.getSubmitId()) {
>        case "remove-selected-contacts":
>            {
>                for (var i = model.contacts.length-1; i >= 0; i--) {
>                    if (model.contacts[i].select) {
>                        model.contacts.remove(i);
>                    }
>                }
>            }
>            break;
>        case "add-contact":
>            {
>                model.contacts.length++;
>            }
>            break;
>        default:
>            return true;
>        }
>        return false;
>    });
>    print("visa="+model.visa);
>    sendPage("form1-success-pipeline");
>    form.finish();
> 
> }
> 
> 
> Regards,
> 
> Chris
> 

-- 
Marc Portier                            http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at              http://radio.weblogs.com/0116284/
mpo@outerthought.org                              mpo@apache.org


Mime
View raw message