You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by ts...@apache.org on 2005/03/27 22:31:43 UTC

svn commit: r159183 [1/4] - in lenya/sandbox: ./ lenya/ lenya/usecases/ lenya/usecases/cformedit/ lenya/usecases/cformedit/flow/ lenya/usecases/cformedit/forms/ lenya/usecases/cformedit/forms/binding/ lenya/usecases/cformedit/resources/

Author: tschlabach
Date: Sun Mar 27 12:31:20 2005
New Revision: 159183

URL: http://svn.apache.org/viewcvs?view=rev&rev=159183
Log:
Sharing the experimental CForm edit usecase (see README.txt)

Added:
    lenya/sandbox/README.txt
    lenya/sandbox/lenya/
    lenya/sandbox/lenya/usecases/
    lenya/sandbox/lenya/usecases/cformedit/
    lenya/sandbox/lenya/usecases/cformedit/.usecase-cformedit.xmap.swp   (with props)
    lenya/sandbox/lenya/usecases/cformedit/flow/
    lenya/sandbox/lenya/usecases/cformedit/flow/binding_example.js
    lenya/sandbox/lenya/usecases/cformedit/flow/bindings.js
    lenya/sandbox/lenya/usecases/cformedit/flow/form_model_gui.js
    lenya/sandbox/lenya/usecases/cformedit/flow/forms_flow_example.js
    lenya/sandbox/lenya/usecases/cformedit/flow/htmlarea.js
    lenya/sandbox/lenya/usecases/cformedit/flow/registration.js
    lenya/sandbox/lenya/usecases/cformedit/flow/upload_example.js
    lenya/sandbox/lenya/usecases/cformedit/forms/
    lenya/sandbox/lenya/usecases/cformedit/forms/a-choices.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/binding/
    lenya/sandbox/lenya/usecases/cformedit/forms/binding/01value-bind.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/binding/01value-data.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/binding/01value-def.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/binding/02lenient-bind.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/binding/02lenient-data.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/binding/02lenient-def.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/binding/03aggregate-bind.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/binding/03aggregate-data.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/binding/03aggregate-def.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/binding/03aggregate-template.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/binding/04heavy-bind.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/binding/04heavy-data.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/binding/04heavy-def.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/binding/04heavy-template.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/binding/05custom-bind.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/binding/05custom-data.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/binding/05custom-def.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/binding/06namespaced-bind.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/binding/06namespaced-data.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/binding/06namespaced-def.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/binding/done.jx
    lenya/sandbox/lenya/usecases/cformedit/forms/car-db.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/carselector_form.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/carselector_success_jx.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/carselector_template.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/countryselector_form.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/countryselector_success_jx.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/countryselector_template.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/datasource_chooser.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/datasource_chooser_binding.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/datasource_chooser_template.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/dynamicrepeater.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/dynamicrepeater_binding.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/dynamicrepeater_template.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/form1.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/form1_success_jx.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/form1_template.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/form1_template_action.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/form2_bind_bean.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/form2_bind_xml.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/form2_data-result.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/form2_data.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/form2_jx.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/form2_model.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/form2_simple_data.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/form2_template.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/form2simpleXML_result.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/form_model_gui_binding.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/form_model_gui_data.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/form_model_gui_model.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/form_model_gui_success_jx.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/form_model_gui_template.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/htmlarea.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/htmlarea_success.jx
    lenya/sandbox/lenya/usecases/cformedit/forms/htmlarea_template.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/linkform_binding.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/linkform_binding.xml.bak
    lenya/sandbox/lenya/usecases/cformedit/forms/linkform_model.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/linkform_template.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/multipage_binding.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/multipage_model.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/multipage_template.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/registration.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/registration_success_jx.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/registration_template.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/tasktree.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/tasktree_binding.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/tasktree_template.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/textresult_template.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/upload_model.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/upload_success_jx.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/upload_template.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/xhr_carselector_form.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/xhr_carselector_template.xml
    lenya/sandbox/lenya/usecases/cformedit/forms/xmlresult_template.xml
    lenya/sandbox/lenya/usecases/cformedit/resources/
    lenya/sandbox/lenya/usecases/cformedit/resources/def2binding.xsl
    lenya/sandbox/lenya/usecases/cformedit/resources/forms-advanced-field-styling.xsl
    lenya/sandbox/lenya/usecases/cformedit/resources/forms-calendar-styling.xsl
    lenya/sandbox/lenya/usecases/cformedit/resources/forms-field-styling.xsl
    lenya/sandbox/lenya/usecases/cformedit/resources/forms-htmlarea-styling.xsl
    lenya/sandbox/lenya/usecases/cformedit/resources/forms-page-styling.xsl
    lenya/sandbox/lenya/usecases/cformedit/resources/forms-samples-styling.xsl
    lenya/sandbox/lenya/usecases/cformedit/usecase-cformedit.xmap

Added: lenya/sandbox/README.txt
URL: http://svn.apache.org/viewcvs/lenya/sandbox/README.txt?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/README.txt (added)
+++ lenya/sandbox/README.txt Sun Mar 27 12:31:20 2005
@@ -0,0 +1,40 @@
+This is an experimental usecase which uses Cocoon Forms (CForms)
+to edit documents of the links resource type from the Default
+publication in 1.4-trunk.
+
+Patching:
+=========
+
+1. Copy the lenya/usecases/cformedit directory to the lenya webapp tree.
+2. (Until fixed) copy the samples/common/xslt subtree from a full Cocoon build
+   to the same location in the Lenya webapp.
+
+Note: 
+
+Step 2 should not be needed any more once the sitemap has been refactored and the form
+will show up inside the Lenya navigation. I just haven't found the time yet but wanted
+to share this code to illustrate the discussion on the dev mailing list.
+
+Trying it:
+==========
+
+- Log into the Default publication as editor
+- Go to the "Links" page
+- add "?lenya.usecase=cformedit&lenya.step=open" to the URL in your browser's address field
+- Enjoy!
+
+To-Do:
+======
+
+- Make sure Cocoon switches to the version of commons-jxpath that works with this,
+  see: http://issues.apache.org/bugzilla/show_bug.cgi?id=34196
+- Remove all unneeded parts copied from the Cocoon sample
+- Fix saving of the edited document with RC etc. Currently the edited file gets saved
+  to a new file index_en-result.xml.
+
+Potential:
+==========
+
+- Investigate if automagic / rule based generation of form model and binding from a 
+  RelaxNG schema are feasible
+

Added: lenya/sandbox/lenya/usecases/cformedit/.usecase-cformedit.xmap.swp
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/.usecase-cformedit.xmap.swp?view=auto&rev=159183
==============================================================================
Binary file - no diff available.

Propchange: lenya/sandbox/lenya/usecases/cformedit/.usecase-cformedit.xmap.swp
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: lenya/sandbox/lenya/usecases/cformedit/flow/binding_example.js
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/flow/binding_example.js?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/flow/binding_example.js (added)
+++ lenya/sandbox/lenya/usecases/cformedit/flow/binding_example.js Sun Mar 27 12:31:20 2005
@@ -0,0 +1,163 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");
+
+// The purpose of the form2 example is to edit the contents of an XML file
+// or a Java bean through a Cocoon form
+
+// the form2 function is not directly called by the sitemap but by
+// a generic "forms" function that instantiates the form based on
+// parameters passed from the sitemap (see above loaded forms.js file)
+function form2xml(form) {
+    // get the documentURI parameter from the sitemap which contains the
+    // location of the file to be edited
+    var documentURI = cocoon.parameters["documentURI"];
+
+    // parse the document to a DOM-tree
+    var document = loadDocument(documentURI);
+
+    // bind the document data to the form
+    form.load(document);
+
+    // show the form to the user until it is validated successfully
+    form.showForm("form2-display-pipeline");
+
+    // bind the form's data back to the document
+    form.save(document);
+
+    // save the DOM-tree back to an XML file, the makeTargetURI
+    // function makes a modified filename so that the
+    // original document is not overwritten
+    saveDocument(document, makeTargetURI(documentURI));
+
+    cocoon.sendPage("form2-success-pipeline");
+}
+
+function form2simpleXML(form) {
+    // get the documentURI parameter from the sitemap which contains the
+    // location of the file to be edited
+    var documentURI = cocoon.parameters["documentURI"];
+
+    // populate the form
+    form.loadXML(documentURI);
+
+    // show the form to the user until it is validated successfully
+    form.showForm("form2-display-pipeline");
+
+    // save the content of the form to a file
+    form.saveXML(makeTargetURI(documentURI));
+
+    // show the xml generated from the form
+    cocoon.sendPage("form2simpleXML-success-pipeline", form.getXML());
+}
+
+// bean variant of the binding sample
+function form2bean(form) {
+    var bean = new Packages.org.apache.cocoon.forms.samples.Form2Bean();
+
+    // fill bean with some data to avoid users having to type to much
+    bean.setEmail("yourname@yourdomain.com");
+    bean.setIpAddress("10.0.0.1");
+    bean.setPhoneCountry("32");
+    bean.setPhoneZone("2");
+    bean.setPhoneNumber("123456");
+    bean.setBirthday(new java.util.Date());
+    bean.setSex(Packages.org.apache.cocoon.forms.samples.Sex.FEMALE);
+    var contact = new Packages.org.apache.cocoon.forms.samples.Contact();
+    contact.setId("1");
+    contact.setFirstName("Hermann");
+    bean.addContact(contact);
+    bean.addDrink("Maes");
+    bean.addDrink("Leffe");
+    
+    form.load(bean);
+    form.showForm("form2-display-pipeline");
+    form.save(bean);
+
+    cocoon.sendPage("form2bean-success-pipeline", { "form2bean": bean });
+}
+
+/**
+ * Translate source path into target path so we keep a clean source XML.
+ */
+function makeTargetURI(path) {
+    var sfx = ".xml";
+    var newSfx = "-result.xml";
+    var newPath = path;
+    if (path.match(/^.*\.xml$/)) {
+        newPath = path.substring(0, path.length - ".xml".length);
+    }
+    return newPath + newSfx;
+}
+
+function loadDocument(uri) {
+    var parser = null;
+    var source = null;
+    var resolver = null;
+    try {
+        parser = cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
+        resolver = cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
+        source = resolver.resolveURI(uri);
+        var is = new Packages.org.xml.sax.InputSource(source.getInputStream());
+        is.setSystemId(source.getURI());
+        return parser.parseDocument(is);
+    } finally {
+        if (source != null)
+            resolver.release(source);
+        cocoon.releaseComponent(parser);
+        cocoon.releaseComponent(resolver);
+    }
+}
+
+function saveDocument(document, uri) {
+    var source = null;
+    var resolver = null;
+    var outputStream = null;
+    try {
+        resolver = cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
+        source = resolver.resolveURI(uri);
+
+        var tf = Packages.javax.xml.transform.TransformerFactory.newInstance();
+
+        if (source instanceof Packages.org.apache.excalibur.source.ModifiableSource
+            && tf.getFeature(Packages.javax.xml.transform.sax.SAXTransformerFactory.FEATURE)) {
+
+            outputStream = source.getOutputStream();
+            var transformerHandler = tf.newTransformerHandler();
+            var transformer = transformerHandler.getTransformer();
+            transformer.setOutputProperty(Packages.javax.xml.transform.OutputKeys.INDENT, "true");
+            transformer.setOutputProperty(Packages.javax.xml.transform.OutputKeys.METHOD, "xml");
+            transformerHandler.setResult(new Packages.javax.xml.transform.stream.StreamResult(outputStream));
+
+            var streamer = new Packages.org.apache.cocoon.xml.dom.DOMStreamer(transformerHandler);
+            streamer.stream(document);
+        } else {
+            throw new Packages.org.apache.cocoon.ProcessingException("Cannot write to source " + uri);
+        }
+    } finally {
+        if (source != null)
+            resolver.release(source);
+        cocoon.releaseComponent(resolver);
+        if (outputStream != null) {
+            try {
+                outputStream.flush();
+                outputStream.close();
+            } catch (error) {
+                cocoon.log.error("Could not flush/close outputstream: " + error);
+            }
+        }
+    }
+}

Added: lenya/sandbox/lenya/usecases/cformedit/flow/bindings.js
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/flow/bindings.js?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/flow/bindings.js (added)
+++ lenya/sandbox/lenya/usecases/cformedit/flow/bindings.js Sun Mar 27 12:31:20 2005
@@ -0,0 +1,296 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");
+
+/** 
+ * Disclaimer: 
+ *   To make this flowscript quite generic we've applied some typical javascript 
+ *   hacks here and there. Don't let them overwhelm you, the purpose of this tutorial
+ *   is _not_ to get into the depths of Cocoon Forms and flowscript. Instead you should 
+ *   focus on the effects of the applied definitions in the binding files:
+ *   see ../forms/bindings/*-bind.xml.  And how to shape your backend-models:
+ *    - for JS see here: createJSBeanfor*() functions
+ *    - for Java see the org.apache.cocoon.forms.samples.bindings.* classes
+ *    - for XML see ../forms/bindings/*-data.xml.
+ *   
+ * In the same area of genericity we are not using the FormsTemplateTransformer 
+ *   since that would require to provide an extra template file to every sample.
+ *
+ * To add more binding-tutorial-samples follow these steps:
+ *  - decide on a sample-code (e.g. '01value')
+ *  - provide a Cocoon Forms formDefinition ../forms/bindings/{sampleCode}-def.xml
+ *  - provide a Cocoon Forms formBinding    ../forms/bindings/{sampleCode}-bind.xml
+ *  - provide the 3 types of backend-models:
+ *    - for JS (javascript) you add here a function createJSBeanFor{sampleCode}()
+ *      and let it return the js object to bind to
+ *    - for Java you create an actual Java class that gets instantiated and returned
+ *      by a function createJavaBeanFor{sampleCode}() over here
+ *    - for XML you create a simple XML file over at
+ *      ../forms/bindings/{sampleCode}-data.xml
+ *  - finally you add a link into the ../welcome.xml page to link to your new sample      
+ */
+
+
+
+
+/**
+ *  Generic entry-function for all binding samples.  This uses the 
+ *   'sample-code' and the 'backend-type' to effectively select the form 
+ *   and specific backend-model to use.
+ */
+function bindingSample(sampleCode, backendType) {
+    // sample-code holds the number-and-name of this binding sample in the tutorial
+    if (cocoon.parameters["sample-code"] != undefined) {
+        sampleCode = cocoon.parameters["sample-code"];
+    }
+	
+    // backend-type holds one of 'JS', 'Java' or 'XML' to indicate 
+    // the type of backend to use.
+    if (cocoon.parameters["backend-type"] != undefined) {
+        backendType = cocoon.parameters["backend-type"];
+    }
+
+    // all back-end models are bound to essentially the same form, using the same binding!
+    var form = createFormForSample(sampleCode);
+
+    // the back-end model itself however depends on sample and type. 
+    var bean = createBeanForSample(backendType, sampleCode);
+	
+	if (bean == null) {
+        cocoon.sendPage("textresult-display-pipeline.jx", {
+            title: "Contact list",
+            text: "Sorry the sample '" + sampleCode +
+                "' is not yet available for the backend '" +
+                backendType + "'"
+            }
+        );
+        return;
+    }
+    // loads the backend-bean into the form
+    form.load(bean);
+
+    // wait for user to submit the form correctly	
+    form.showForm("binding.form." + sampleCode);
+	
+    // saves the form into the backend-bean
+    form.save(bean);
+    var bizData = new Object();
+    // hack the XML content to a string for display
+    if (backendType.equals("XML")) {
+    	bean = {xml: serializeNode(bean)};
+    }
+    bizData["bean"] = bean;
+    bizData["backendType"] = backendType;
+    bizData["sampleCode"] = sampleCode;
+
+    cocoon.sendPage("binding.done", bizData);
+}
+
+/** 
+ * Uses internal cocoon utility class to convert the DOM Node to it's 
+ * String representation .
+ */
+function serializeNode(node) {
+    return Packages.org.apache.cocoon.xml.XMLUtils.serializeNodeToXML(node);
+}
+
+/** 
+ * Creates the form for this sample. And automatically creates the accompanied 
+ * binding.
+ */
+function createFormForSample(sampleCode) {
+    var form = new Form("forms/binding/" + sampleCode + "-def.xml");
+    form.createBinding("forms/binding/" + sampleCode +"-bind.xml");
+    return form;
+}
+
+/** 
+ * Creates the Bean of the desired type for this sample.
+ */
+function createBeanForSample(backendType, sampleCode) {
+    if (backendType.equals("XML")) {
+        return createXMLBean(sampleCode);
+    } else {
+        var factoryFunction = "create" + backendType + "BeanFor" + sampleCode;
+        print("Using the bean returned by function " + factoryFunction + "()");
+        if (this[factoryFunction]) {
+            return this[factoryFunction].apply();
+        } else {
+            return null; // not available
+        }
+    }
+}
+
+/** 
+ * Finds the sample specific XML file to bind to and parses it into a DOM Document.
+ */
+function createXMLBean(sampleCode) {
+    // note if you want to toss around with the XML model (e.g. sample 02lenient)
+    // then you should do that by editing the files: ../forms/binding/*-data.xml
+
+    var uri = "forms/binding/" + sampleCode +"-data.xml";
+    print("Using the XML data file at " + uri);
+
+    var parser = null;
+    var source = null;
+    var resolver = null;
+    try {
+        parser = cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
+        resolver = cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
+        source = resolver.resolveURI(uri);
+        var is = new Packages.org.xml.sax.InputSource(source.getInputStream());
+        is.setSystemId(source.getURI());
+        //Note: we immediately narrow down to the root-element here to avoid
+        // needing to wrap js and Java beans in a silly 'root'
+        return parser.parseDocument(is).getDocumentElement();
+    } finally {
+        if (source != null)
+            resolver.release(source);
+        cocoon.releaseComponent(parser);
+        cocoon.releaseComponent(resolver);
+    }
+}	
+
+/**
+ * Creates the JS Bean for sample '01value'
+ */ 
+function createJSBeanFor01value() {
+    var bean;
+    bean = new Object();
+    bean.simple = "Simple";
+    bean.readOnly = "Read-Only";
+    bean.writeOnly = "Write-Only";
+    bean.diffIn = "Diff-in/out";
+    // diffOut doesn't need to exist, binding will create it.
+    bean.onUpdate = "On Update";
+    bean.updateCount = 0;
+    bean.bool = true;
+    bean.date = "19700605";
+    bean.other = "This field is not involved in the form.";
+    return bean;
+}
+
+/**
+ * Creates the Java Bean for sample '01value'
+ */ 
+function createJavaBeanFor01value() {
+    return new Packages.org.apache.cocoon.forms.samples.bindings.ValuesBean();
+}
+
+/**
+ * Creates the JS Bean for sample '02lenient'
+ */ 
+function createJSBeanFor02lenient() {
+    var bean = new Object();
+    var contexts = ["one","two","three"];	  
+    for(var i=0; i<contexts.length; i++) {
+        bean[contexts[i]] = new Object();
+        // using javascript beans seem to survive even non lenient binding
+        // so you can do here what you want, the bean itself seems to be leninet?
+        //bean[contexts[i]]["breakingField"] = "present";
+    }
+    return bean;
+}
+
+/**
+ * Creates the Java Bean for sample '02lenient'
+ */ 
+function createJavaBeanFor02lenient() {
+    var bean = new Packages.java.util.HashMap();
+    // to see the runtime effect of non-lenient binding
+    // remove/replace the 'one' in the following list:
+    var contexts = ["one","two","three"];	  // only the 'one' context is required by non-lenient binding
+        for(var i=0; i<contexts.length; i++) {
+        // to see the runtime effect of non-lenient binding
+        // swap the following 2 lines from comment to code 
+            var subBean = new Packages.org.apache.cocoon.forms.samples.bindings.LenientOKBean("init");
+//            var subBean = new Packages.org.apache.cocoon.forms.samples.bindings.LenientNotOKBean("init");
+	    
+            // the NotOkBean does not have a getBreakingField() required by the non-lenient binding
+
+            bean.put(contexts[i], subBean);
+    }
+    return bean;
+}
+
+
+/**
+ * Creates the JS Bean for sample '03aggregate'
+ */ 
+function createJSBeanFor03aggregate() {
+    var bean = new Object();
+    bean["match-combined"] = new Object();
+    bean["match-combined"].split = new Object();
+    bean["match-combined"].split.day = "7";
+    bean["match-combined"].split.month = "4";
+    bean["match-combined"].split.year = "2004";
+
+    bean["match-split"] = new Object();    
+    bean["match-split"].combined = "07/04/2004";
+    bean["match-split"].split = new Object();
+    return bean;
+}
+
+/**
+ * Creates the Java Bean for sample '03aggregate'
+ */ 
+function createJavaBeanFor03aggregate() {
+    var bean = new Packages.java.util.HashMap();
+    bean.put("match-combined", new Packages.org.apache.cocoon.forms.samples.bindings.DateWrapper("07","04","2004"));
+    bean.put("match-split", new Packages.org.apache.cocoon.forms.samples.bindings.DateWrapper("07","04","2004"));
+    return bean;
+}
+
+/**
+ * sample conversion methods used by the javascript binding in '05custom'
+ */
+
+function doLoadConversion(backendValue, delimiter){
+  var presuffix = "" + delimiter + delimiter;
+  var result = "";
+  if (backendValue.startsWith(presuffix) 
+      && backendValue.endsWith(presuffix)
+      && backendValue.length() >= 4) {
+    result = backendValue.substring(2,backendValue.length() - 2);
+  }
+  return result;
+}
+
+function doSaveConversion(formValue, delimiter){
+  var result = "" + delimiter + delimiter + formValue + delimiter + delimiter;
+  return result;
+}
+
+/**
+ * Creates the JS Bean for sample '05custom'
+ */ 
+function createJSBeanFor05custom() {
+    var bean = {"jswrap-value": "--wrapped value--",
+                "custom-value": "**custom value**",
+                "config-value": "[[config value]]"};
+    return bean;
+}
+
+/**
+ * Creates the Java Bean for sample '05custom'
+ */ 
+function createJavaBeanFor05custom() {
+    var bean = new Packages.java.util.HashMap();
+    bean.put("jswrap-value", "--wrapped value--");
+    bean.put("custom-value", "**custom value**");
+    bean.put("config-value", "[[config value]]");
+    return bean;
+}

Added: lenya/sandbox/lenya/usecases/cformedit/flow/form_model_gui.js
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/flow/form_model_gui.js?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/flow/form_model_gui.js (added)
+++ lenya/sandbox/lenya/usecases/cformedit/flow/form_model_gui.js Sun Mar 27 12:31:20 2005
@@ -0,0 +1,139 @@
+/*
+* Copyright 1999-2004 The Apache Software Foundation
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/*
+* @version $Id: form_model_gui.js 151173 2005-02-03 16:07:11Z tim $
+*/
+
+cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");
+
+function form_model_gui(form) {
+
+    var locale = determineLocale();
+    var model = form.getModel();
+    form.locale = locale;
+
+    // get the documentURI parameter from the sitemap which
+    // contains the location of the file to be edited
+    var documentURI = cocoon.parameters["documentURI"];
+
+    // parse the document to a DOM-tree
+    var document = loadDocument(documentURI);
+
+    // bind the document data to the form
+    form.load(document);
+
+    // show the form
+    form.showForm("form_model_gui-display-pipeline");
+    print("submitId = " + form.submitId);
+    if (form.isValid) {
+      print("Form is valid");  
+    } else {
+      print("Form is not valid");
+    }
+
+    // bind the form's data back to the document
+    form.save(document);
+
+    // save the DOM-tree back to an XML file, the makeTargetURI
+    // function makes a modified filename so that the
+    // original document is not overwritten
+    saveDocument(document, makeTargetURI(documentURI));
+
+    // also store the form as a request attribute as the XSP isn't flow-aware
+    cocoon.request.setAttribute("form_model_gui", form.getWidget());
+    cocoon.sendPage("form_model_gui-success-pipeline.xsp");
+}
+
+function determineLocale() {
+    var localeParam = cocoon.request.get("locale");
+    if (localeParam != null && localeParam.length > 0) {
+        return Packages.org.apache.cocoon.i18n.I18nUtils.parseLocale(localeParam);
+    }
+    return null;
+}
+
+/**
+ * Translate source path into target path so we keep a clean source XML.
+ */
+function makeTargetURI(path) {
+    var sfx = ".xml";
+    var newSfx = "-result.xml";
+    var newPath = path;
+    if (path.match(/^.*\.xml$/)) {
+        newPath = path.substring(0, path.length - ".xml".length);
+    }
+    return newPath + newSfx;
+}
+
+function loadDocument(uri) {
+    var parser = null;
+    var source = null;
+    var resolver = null;
+    try {
+        parser = cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
+        resolver = cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
+        source = resolver.resolveURI(uri);
+        var is = new Packages.org.xml.sax.InputSource(source.getInputStream());
+        is.setSystemId(source.getURI());
+        return parser.parseDocument(is);
+    } finally {
+        if (source != null)
+            resolver.release(source);
+        cocoon.releaseComponent(parser);
+        cocoon.releaseComponent(resolver);
+    }
+}
+
+function saveDocument(document, uri) {
+    var source = null;
+    var resolver = null;
+    var outputStream = null;
+    try {
+        resolver = cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
+        source = resolver.resolveURI(uri);
+
+        var tf = Packages.javax.xml.transform.TransformerFactory.newInstance();
+
+        if (source instanceof Packages.org.apache.excalibur.source.ModifiableSource
+            && tf.getFeature(Packages.javax.xml.transform.sax.SAXTransformerFactory.FEATURE)) {
+
+            outputStream = source.getOutputStream();
+            var transformerHandler = tf.newTransformerHandler();
+            var transformer = transformerHandler.getTransformer();
+            transformer.setOutputProperty(Packages.javax.xml.transform.OutputKeys.INDENT, "true");
+            transformer.setOutputProperty(Packages.javax.xml.transform.OutputKeys.METHOD, "xml");
+            transformerHandler.setResult(new Packages.javax.xml.transform.stream.StreamResult(outputStream));
+
+            var streamer = new Packages.org.apache.cocoon.xml.dom.DOMStreamer(transformerHandler);
+            streamer.stream(document);
+        } else {
+            throw new Packages.org.apache.cocoon.ProcessingException("Cannot write to source " + uri);
+        }
+    } finally {
+        if (source != null)
+            resolver.release(source);
+        cocoon.releaseComponent(resolver);
+        if (outputStream != null) {
+            try {
+                outputStream.flush();
+                outputStream.close();
+            } catch (error) {
+                cocoon.log.error("Could not flush/close outputstream: " + error);
+            }
+        }
+    }
+}

Added: lenya/sandbox/lenya/usecases/cformedit/flow/forms_flow_example.js
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/flow/forms_flow_example.js?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/flow/forms_flow_example.js (added)
+++ lenya/sandbox/lenya/usecases/cformedit/flow/forms_flow_example.js Sun Mar 27 12:31:20 2005
@@ -0,0 +1,150 @@
+/*
+* Copyright 1999-2004 The Apache Software Foundation
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");
+
+function form1(form) {
+    var locale = determineLocale();
+    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.birthdate = new java.util.Date();
+    
+    model.contacts[0].firstname = "Jules";
+    model.contacts[1].firstname =  "Lucien";
+    model.contacts[2].firstname = "Chris";
+    model.drinks = ["Jupiler", "Coca Cola"];
+
+    form.locale = locale;
+    form.showForm("form1-display-pipeline.jx");
+    print("submitId = " + form.submitId);
+    if (form.isValid) {
+      print("visa=" + model.visa);  
+    } else {
+      print("Form is not valid");
+    }
+    // also store the form as a request attribute as the XSP isn't flow-aware
+    cocoon.request.setAttribute("form1", form.getWidget());
+    cocoon.sendPage("form1-success-pipeline.xsp");
+}
+
+function selectCar() {
+    var form = new Form("forms/carselector_form.xml");
+    form.lookupWidget("make").setValue(cocoon.parameters.defaultMake);
+    form.showForm("carselector-display-pipeline");
+    cocoon.request.setAttribute("carselectorform", form.getWidget());
+    cocoon.sendPage("carselector-success-pipeline.xsp");
+}
+
+function xhrSelectCar() {
+    var form = new Form("forms/xhr_carselector_form.xml");
+    // form.lookupWidget("make").setValue(cocoon.parameters.defaultMake);
+    form.showForm("xhr_carselector-display-pipeline");
+    cocoon.request.setAttribute("carselectorform", form.getWidget());
+    cocoon.sendPage("carselector-success-pipeline.xsp");
+}
+
+var states = [
+    { key: "AL", value: "Alabama" },
+    { key: "AK", value: "Alaska" },
+    { key: "WY", value: "Wyoming" }
+];
+
+var countries = [
+    { key: "ad", value: "Andorra, Principality of" },
+    { key: "zw", value: "Zimbabwe" }
+];
+
+function selectCountry() {
+    var form = new Form("forms/countryselector_form.xml");
+    form.showForm("countryselector-display-pipeline");
+    cocoon.request.setAttribute("countryselectorform", form.getWidget());
+    cocoon.sendPage("countryselector-success-pipeline.xsp");
+}
+
+function determineLocale() {
+    var localeParam = cocoon.request.get("locale");
+    if (localeParam != null && localeParam.length > 0) {
+        return Packages.org.apache.cocoon.i18n.I18nUtils.parseLocale(localeParam);
+    }
+    return null;
+}
+
+function do_dynaRepeater() {
+    var form = new Form("forms/dynamicrepeater.xml");
+    form.setAttribute("counter", new java.lang.Integer(0));
+    form.showForm("dynamicrepeater-display-pipeline.jx");
+    
+    var doc = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+    doc.appendChild(doc.createElement("contacts"));
+    form.createBinding("forms/dynamicrepeater_binding.xml");
+    
+    form.save(doc);
+    cocoon.sendPage("xmlresult-display-pipeline.jx",
+        {title: "Contact list", document: doc}
+    );
+}
+
+function do_datasourceChooser() {
+    var form = new Form("forms/datasource_chooser.xml");
+    form.showForm("datasource_chooser-display-pipeline.jx");
+    
+    var doc = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+    doc.appendChild(doc.createElement("config"));
+    form.createBinding("forms/datasource_chooser_binding.xml");
+    form.save(doc);
+    
+    cocoon.sendPage("xmlresult-display-pipeline.jx",
+        {title: "Here's the datasource definition", document: doc}
+    );
+}
+
+function do_taskTree() {
+    var form = new Form("forms/tasktree.xml");
+    form.showForm("tasktree-display-pipeline.jx");
+    
+    var doc = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+    doc.appendChild(doc.createElement("project"));
+    form.createBinding("forms/tasktree_binding.xml");
+    form.save(doc);
+    
+    cocoon.sendPage("xmlresult-display-pipeline.jx",
+        {title: "Here's the resulting project definition", document: doc}
+    );
+}
+
+// import WidgetState for direct access in event handlers.
+// FIXME(SW) would be better to import it implicitely within Forms.js
+importClass(org.apache.cocoon.forms.formmodel.WidgetState);
+
+function do_multipage() {
+    var form = new Form("forms/multipage_model.xml");
+    form.showForm("multipage-display-pipeline.jx");
+    
+    var doc = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+    doc.appendChild(doc.createElement("result"));
+    form.createBinding("forms/multipage_binding.xml");
+    form.save(doc);
+    
+    cocoon.sendPage("xmlresult-display-pipeline.jx",
+        {title: "Here's the resulting document", document: doc}
+    );
+}
+
+

Added: lenya/sandbox/lenya/usecases/cformedit/flow/htmlarea.js
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/flow/htmlarea.js?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/flow/htmlarea.js (added)
+++ lenya/sandbox/lenya/usecases/cformedit/flow/htmlarea.js Sun Mar 27 12:31:20 2005
@@ -0,0 +1,29 @@
+/*
+* Copyright 1999-2004 The Apache Software Foundation
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");
+
+function htmlarea() {
+    var form = new Form("forms/htmlarea.xml");
+
+    form.showForm("htmlarea-display-pipeline");
+
+    var model = form.getModel();
+    var htmldata = { 
+                      "data1" : model.data1,
+                      "data2" : new Packages.org.apache.cocoon.xml.StringXMLizable(model.data2)
+                   }
+    cocoon.sendPage("htmlarea-success-pipeline", htmldata);
+}

Added: lenya/sandbox/lenya/usecases/cformedit/flow/registration.js
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/flow/registration.js?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/flow/registration.js (added)
+++ lenya/sandbox/lenya/usecases/cformedit/flow/registration.js Sun Mar 27 12:31:20 2005
@@ -0,0 +1,28 @@
+/*
+* Copyright 1999-2004 The Apache Software Foundation
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");
+
+function registration() {
+    var form = new Form("forms/registration.xml");
+
+    // The showForm function will keep redisplaying the form until
+    // everything is valid
+    form.showForm("registration-display-pipeline");
+
+    var model = form.getModel();
+    var bizdata = { "username" : model.name }
+    cocoon.sendPage("registration-success-pipeline.jx", bizdata);
+}

Added: lenya/sandbox/lenya/usecases/cformedit/flow/upload_example.js
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/flow/upload_example.js?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/flow/upload_example.js (added)
+++ lenya/sandbox/lenya/usecases/cformedit/flow/upload_example.js Sun Mar 27 12:31:20 2005
@@ -0,0 +1,51 @@
+/*
+* Copyright 1999-2004 The Apache Software Foundation
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");
+
+function upload() {
+    
+    var form = new Form("forms/upload_model.xml");
+    var k = form.showForm("upload-display-pipeline");
+
+    k.invalidate();
+
+    cocoon.sendPage("upload-success-pipeline.jx",
+        {
+            uploadContent: handleUpload(form), 
+            username: form.lookupWidget("user").getValue(),
+            filename: form.lookupWidget("upload").getValue().getHeaders().get("filename")
+        }
+    );
+}
+
+function handleUpload(form) {
+
+  var buf = new java.lang.StringBuffer();
+  
+  var uploadWidget = form.lookupWidget("upload");
+  if (uploadWidget.getValue() != null) {
+    var stream = uploadWidget.getValue().getInputStream();
+    var reader = new java.io.BufferedReader(new java.io.InputStreamReader(stream));
+
+    var line;
+    while ((line=reader.readLine())!=null)
+      buf.append(line).append("\n");
+
+    reader.close();
+  }
+  
+  return buf.toString();
+}

Added: lenya/sandbox/lenya/usecases/cformedit/forms/a-choices.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/a-choices.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/a-choices.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/a-choices.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<fd:selection-list xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">
+  <fd:item value="a"/>
+  <fd:item value="aa"/>
+  <fd:item value="aaa"/>
+  <fd:item value="aaaa"/>
+  <fd:item value="aaaaa"/>
+</fd:selection-list>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/binding/01value-bind.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/binding/01value-bind.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/binding/01value-bind.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/binding/01value-bind.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,96 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding" 
+            xmlns:fd="http://apache.org/cocoon/forms/1.0#definition" 
+	    path="/" >
+
+<!-- 
+   | This file shows the different possibilities for (single) Value Binding 
+   | of the Binding Framework in Cocoon Forms.
+   -->
+
+
+  <!-- 
+     | SECTION 1. Default simple value-binding 
+     -->
+  <fb:value id="simple"   
+            path="simple" />
+            
+
+  <!-- 
+     | SECTION 2. Playing around with @direction
+     -->
+
+  <!-- Binding only during load() -->
+  <fb:value id="readonly"   
+            path="readOnly" direction="load"/>
+            
+  <!-- Binding only during save() -->          
+  <fb:value id="writeonly"   
+            path="writeOnly" direction="save"/>
+            
+  <!-- Binding working to different targets for 
+       load() and save() -->
+  <fb:value id="diff"   
+            path="diffIn" direction="load"/>            
+  <fb:value id="diff"   
+            path="diffOut" direction="save"/>
+            
+            
+  <!-- 
+     | SECTION 3. Using the 'on-update'
+     -->
+               
+  <!-- Binding executing additional action on save()
+       if the value changed -->          
+  <fb:value id="onupdate"   
+            path="onUpdate" >
+    <fb:on-update>
+      <fb:javascript id="onupdate" path="..">
+        <fb:load-form />
+        <fb:save-form>
+          var countPointer = jxpathContext.getPointer('updateCount');
+          var count = parseInt(countPointer.getValue()) + 1;
+          countPointer.setValue(count);
+        </fb:save-form>
+      </fb:javascript>
+    </fb:on-update>          
+  </fb:value>
+            
+            
+  <!-- 
+     | SECTION 4. Matching value types and data-conversion
+     -->
+            
+  <!-- Boolean Binding just works -->          
+  <fb:value id="bool"   
+            path="bool">
+    <fd:convertor datatype="boolean" />
+  </fb:value>
+                        
+  <!-- Converting data-types to/from String values -->
+  <fb:value id="date"   
+            path="date" >
+    <fd:convertor datatype="date" >
+      <fd:patterns>
+        <fd:pattern>yyyyMMdd</fd:pattern>
+      </fd:patterns>
+    </fd:convertor>
+  </fb:value>
+  
+</fb:context>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/binding/01value-data.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/binding/01value-data.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/binding/01value-data.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/binding/01value-data.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<root>
+  <simple test="nothing">Simple</simple>
+  <readOnly>Read-Only</readOnly>
+  <writeonly>Write-Only</writeonly>
+  <diffIn>Diff-In/Out</diffIn>
+  <!-- diffOut doesn't need to exist since the binding
+       by default will create it. (not here though, but at the end...) -->
+  <onUpdate>On Update</onUpdate>
+  <updateCount>0</updateCount>
+  <bool>true</bool>
+  <date>19700506</date>
+</root>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/binding/01value-def.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/binding/01value-def.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/binding/01value-def.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/binding/01value-def.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,64 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">
+
+  <fd:widgets>
+  
+    <fd:field id="simple" >
+      <fd:label>String - bound in both directions:</fd:label>
+      <fd:datatype base="string" />
+    </fd:field>
+
+    <fd:field id="readonly" >
+      <fd:label>String - bound only during load:</fd:label>
+      <fd:datatype base="string" />
+    </fd:field>
+
+    <fd:field id="writeonly" required="true">
+      <fd:label>String - bound only during save:</fd:label>
+      <fd:datatype base="string" />
+    </fd:field>
+
+    <fd:field id="diff" >
+      <fd:label>String - bound in both directions but to different locations:</fd:label>
+      <fd:datatype base="string" />
+    </fd:field>
+    
+    <fd:field id="onupdate" >
+      <fd:label>String - with extra binding &lt;on-update&gt;</fd:label>
+      <fd:datatype base="string" />
+    </fd:field>
+    
+    <fd:booleanfield id="bool">
+      <fd:label>Boolean Value</fd:label>
+    </fd:booleanfield>
+
+
+    <fd:field id="date">
+      <fd:label>Date - with different convertor for binding.</fd:label>
+      <fd:datatype base="date" >
+        <fd:convertor>
+          <fd:patterns>
+            <fd:pattern>dd/MM/yyyy</fd:pattern>
+          </fd:patterns>
+        </fd:convertor>
+      </fd:datatype>
+    </fd:field>
+    
+  </fd:widgets>
+</fd:form>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/binding/02lenient-bind.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/binding/02lenient-bind.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/binding/02lenient-bind.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/binding/02lenient-bind.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding" 
+            xmlns:fd="http://apache.org/cocoon/forms/1.0#definition" 
+	    path="/" 
+	    direction="load" >
+
+<!-- 
+   | This file shows the inheritance behaviour of the @lenient setting 
+   | on the various bindings in the framework. 
+   | You will need to edit the backend-model in the script to see the effect
+   |  see: ../../flow/bindings.js#createLenientTestObject()
+   -->
+   
+  <!-- following 3 bindings work identical, see how inheritance and
+       default settings do their work -->
+        
+  <fb:context path="one" lenient="false">
+    <!-- to override inherit from .. explicitely set 'true' -->
+    <fb:value id="anyfield" path="surviveField" lenient="true" />
+    <!-- inherit from .. becomes 'false' -->
+    <fb:value id="anyfield" path="breakingField" />
+  </fb:context>
+            
+  <fb:context path="two" lenient="true">
+    <!-- inherit from .. becomes 'true' -->
+    <fb:value id="anyfield" path="surviveField" />
+    <!-- to override inherit from .. explicitely set 'false' -->
+    <fb:value id="anyfield" path="breakingField" lenient="false"/>
+  </fb:context>
+            
+  <fb:context path="three" >
+    <!-- inherit from ../.. becomes 'true' (the default for the root) -->
+    <fb:value id="anyfield" path="surviveField" />
+    <!-- to override inherit from ../.. explicitely set 'false' -->
+    <fb:value id="anyfield" path="breakingField" lenient="false"/>
+  </fb:context>
+
+</fb:context>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/binding/02lenient-data.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/binding/02lenient-data.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/binding/02lenient-data.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/binding/02lenient-data.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<root>
+  <!-- to see the runtime effect of non-lenient binding
+       comment out one of the 'breakingField' nodes below -->
+       
+  <!-- an element named 'one' is required by non-lenient binding -->     
+  <one>
+    <!-- 'breakingField' is required by non-lenient binding -->
+    <breakingField>init1</breakingField>
+  </one>
+
+  <!-- elements 'two' and 'three' are optional, but if present, then non-lenient
+       binding requires them to have a 'breakingField' child attribute -->
+  <two>
+    <breakingField>init2</breakingField>
+  </two>
+  <three>
+    <breakingField>init3</breakingField>
+  </three>
+</root>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/binding/02lenient-def.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/binding/02lenient-def.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/binding/02lenient-def.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/binding/02lenient-def.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">
+
+  <fd:widgets>
+  
+    <fd:field id="anyfield" >
+      <fd:label>String - Only one, bound to various paths in the model</fd:label>
+      <fd:datatype base="string" />
+    </fd:field>
+    
+  </fd:widgets>
+  
+</fd:form>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/binding/03aggregate-bind.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/binding/03aggregate-bind.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/binding/03aggregate-bind.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/binding/03aggregate-bind.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,66 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding" 
+            xmlns:fd="http://apache.org/cocoon/forms/1.0#definition" 
+	    path="/" >
+
+  <fb:context path="match-combined">
+    <fb:aggregate id="date-combined" path="split">
+      <fb:value id="day" path="day">
+        <fd:convertor datatype="integer" />
+      </fb:value>
+      <fb:value id="month" path="month">
+        <fd:convertor datatype="integer" />
+      </fb:value>
+      <fb:value id="year" path="year">
+        <fd:convertor datatype="integer" />
+      </fb:value>
+    </fb:aggregate>
+  
+    <fb:value id="date-combined" path="combined" direction="save">
+      <fd:convertor datatype="date" >
+        <fd:patterns>
+          <fd:pattern>dd/MM/yyyy</fd:pattern>
+        </fd:patterns>
+      </fd:convertor>
+    </fb:value>
+  </fb:context>
+  
+  <fb:context path="match-split">
+    <fb:aggregate id="date-split" path="split" direction="save">
+      <fb:value id="day" path="day">
+        <fb:convertor datatype="integer" />
+      </fb:value>
+      <fb:value id="month" path="month">
+        <fb:convertor datatype="integer" />
+      </fb:value>
+      <fb:value id="year" path="year">
+        <fb:convertor datatype="integer" />
+      </fb:value>
+    </fb:aggregate>
+  
+    <fb:value id="date-split" path="combined" >
+      <fd:convertor datatype="date" >
+        <fd:patterns>
+          <fd:pattern>dd/MM/yyyy</fd:pattern>
+        </fd:patterns>
+      </fd:convertor>
+    </fb:value>
+  </fb:context>
+    
+</fb:context>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/binding/03aggregate-data.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/binding/03aggregate-data.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/binding/03aggregate-data.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/binding/03aggregate-data.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<root>     
+  <match-combined>
+    <combined/>
+    <split>
+      <day>07</day>
+      <month>04</month>
+      <year>2004</year>
+    </split>
+  </match-combined>
+  <match-split>
+    <combined>07/04/2004</combined>
+    <split/>
+  </match-split>
+</root>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/binding/03aggregate-def.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/binding/03aggregate-def.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/binding/03aggregate-def.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/binding/03aggregate-def.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,224 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">
+
+  <fd:widgets>
+  
+     <fd:aggregatefield id="date-combined" required="true">
+      <fd:label>
+        Enter Date
+        <br/><small>(Format is: dd/MM/yyyy)
+        <br/>Year should be between 1990 and 2010. Day should be between 1 to 15</small>
+      </fd:label>
+      <fd:datatype base="date">
+        <fd:convertor>
+          <fd:patterns>
+            <fd:pattern>dd/MM/yyyy</fd:pattern>
+          </fd:patterns>
+        </fd:convertor>
+        <fd:validation>
+          <fd:range min="Date(1990, 1, 1)" max="Date(2010, 12, 31)">
+            <fd:failmessage>Enter date in 1990 to 2010 year</fd:failmessage>
+          </fd:range>
+        </fd:validation>
+      </fd:datatype>
+
+      <fd:split pattern="([0-9]{1,2})/([0-9]{1,2})/([0-9]{4})">
+        <fd:map group="1" field="day"/>
+        <fd:map group="2" field="month"/>
+        <fd:map group="3" field="year"/>
+        <fd:failmessage>Not a valid date.</fd:failmessage>
+      </fd:split>
+      <fd:combine expression='Date(year, month, day)'/>
+
+      <fd:widgets>
+        <fd:field id="day" required="true">
+          <fd:datatype base="integer"/>
+          <fd:label>
+            Enter Day
+            <br/><small>(Day should be between 1 to 15)</small>
+          </fd:label>
+          <fd:validation>
+            <fd:range min="1" max="15">
+              <fd:failmessage>Enter date between 1st and 15th day of the month.</fd:failmessage>
+            </fd:range>
+          </fd:validation>
+        </fd:field>
+        <fd:field id="month" required="true">
+          <fd:label>
+            Enter Month
+            <br/><small>(Month should be between 1 to 12)</small>
+          </fd:label>
+          <fd:datatype base="integer"/>
+          <fd:selection-list>
+            <fd:item value="">
+              <fd:label>Select Month</fd:label>
+            </fd:item>
+            <fd:item value="1">
+              <fd:label>January</fd:label>
+            </fd:item>
+            <fd:item value="2">
+              <fd:label>February</fd:label>
+            </fd:item>
+            <fd:item value="3">
+              <fd:label>March</fd:label>
+            </fd:item>
+            <fd:item value="4">
+              <fd:label>April</fd:label>
+            </fd:item>
+            <fd:item value="5">
+              <fd:label>May</fd:label>
+            </fd:item>
+            <fd:item value="6">
+              <fd:label>June</fd:label>
+            </fd:item>
+            <fd:item value="7">
+              <fd:label>July</fd:label>
+            </fd:item>
+            <fd:item value="8">
+              <fd:label>August</fd:label>
+            </fd:item>
+            <fd:item value="9">
+              <fd:label>September</fd:label>
+            </fd:item>
+            <fd:item value="10">
+              <fd:label>October</fd:label>
+            </fd:item>
+            <fd:item value="11">
+              <fd:label>November</fd:label>
+            </fd:item>
+            <fd:item value="12">
+              <fd:label>December</fd:label>
+            </fd:item>
+          </fd:selection-list>
+        </fd:field>
+        <fd:field id="year" required="true">
+          <fd:label>
+            Enter Year
+            <br/><small>(Year should be between 1990 to 2010)</small>
+          </fd:label>
+          <fd:datatype base="integer"/>
+        </fd:field>
+      </fd:widgets>
+    </fd:aggregatefield>
+
+
+    <!-- if ever we were looking for a good reason to introduce
+         the @define and @extends for widget-reuse,
+         here is the same thing again with just a different id: -->
+    <fd:aggregatefield id="date-split" required="true">
+      <fd:label>
+        Enter Date
+        <br/><small>(Format is: dd/MM/yyyy)
+        <br/>Year should be between 1990 and 2010. Day should be between 1 to 15</small>
+      </fd:label>
+      <fd:datatype base="date">
+        <fd:convertor>
+          <fd:patterns>
+            <fd:pattern>dd/MM/yyyy</fd:pattern>
+          </fd:patterns>
+        </fd:convertor>
+        <fd:validation>
+          <fd:range min="Date(1990, 1, 1)" max="Date(2010, 12, 31)">
+            <fd:failmessage>Enter date in 1990 to 2010 year</fd:failmessage>
+          </fd:range>
+        </fd:validation>
+      </fd:datatype>
+
+      <fd:split pattern="([0-9]{1,2})/([0-9]{1,2})/([0-9]{4})">
+        <fd:map group="1" field="day"/>
+        <fd:map group="2" field="month"/>
+        <fd:map group="3" field="year"/>
+        <fd:failmessage>Not a valid date.</fd:failmessage>
+      </fd:split>
+      <fd:combine expression='Date(year, month, day)'/>
+
+      <fd:widgets>
+        <fd:field id="day" required="true">
+          <fd:datatype base="integer"/>
+          <fd:label>
+            Enter Day
+            <br/><small>(Day should be between 1 to 15)</small>
+          </fd:label>
+          <fd:validation>
+            <fd:range min="1" max="15">
+              <fd:failmessage>Enter date between 1st and 15th day of the month.</fd:failmessage>
+            </fd:range>
+          </fd:validation>
+        </fd:field>
+        <fd:field id="month" required="true">
+          <fd:label>
+            Enter Month
+            <br/><small>(Month should be between 1 to 12)</small>
+          </fd:label>
+          <fd:datatype base="integer"/>
+          <fd:selection-list>
+            <fd:item value="">
+              <fd:label>Select Month</fd:label>
+            </fd:item>
+            <fd:item value="1">
+              <fd:label>January</fd:label>
+            </fd:item>
+            <fd:item value="2">
+              <fd:label>February</fd:label>
+            </fd:item>
+            <fd:item value="3">
+              <fd:label>March</fd:label>
+            </fd:item>
+            <fd:item value="4">
+              <fd:label>April</fd:label>
+            </fd:item>
+            <fd:item value="5">
+              <fd:label>May</fd:label>
+            </fd:item>
+            <fd:item value="6">
+              <fd:label>June</fd:label>
+            </fd:item>
+            <fd:item value="7">
+              <fd:label>July</fd:label>
+            </fd:item>
+            <fd:item value="8">
+              <fd:label>August</fd:label>
+            </fd:item>
+            <fd:item value="9">
+              <fd:label>September</fd:label>
+            </fd:item>
+            <fd:item value="10">
+              <fd:label>October</fd:label>
+            </fd:item>
+            <fd:item value="11">
+              <fd:label>November</fd:label>
+            </fd:item>
+            <fd:item value="12">
+              <fd:label>December</fd:label>
+            </fd:item>
+          </fd:selection-list>
+        </fd:field>
+        <fd:field id="year" required="true">
+          <fd:label>
+            Enter Year
+            <br/><small>(Year should be between 1990 to 2010)</small>
+          </fd:label>
+          <fd:datatype base="integer"/>
+        </fd:field>
+      </fd:widgets>
+    </fd:aggregatefield>
+    
+  </fd:widgets>
+  
+</fd:form>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/binding/03aggregate-template.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/binding/03aggregate-template.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/binding/03aggregate-template.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/binding/03aggregate-template.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!--+
+    | CForms aggregate sample binding. Represent values of two aggregate
+    | fields as single input fields.
+    |
+    | @version $Id: 03aggregate-template.xml 151180 2005-02-03 16:56:09Z tim $
+    +-->
+<page xmlns:ft="http://apache.org/cocoon/forms/1.0#template" 
+      xmlns:fi="http://apache.org/cocoon/forms/1.0#instance" 
+      xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+  <title>Aggregate Field Binding</title>
+  <content>
+    <p>
+      On this form, you can enter a date, either split over it's parts or as one entry.
+    </p>
+
+    <ft:form-template>
+      <fi:group>
+        <fi:styling layout="columns" />
+        <fi:items>
+          <ft:widget id="date-combined"/>
+      
+          <ft:aggregate-widget id="date-split">
+            <ft:widget id="day"/>
+            <ft:widget id="month"/>
+            <ft:widget id="year"/>
+          </ft:aggregate-widget>
+        </fi:items>
+      </fi:group>
+      
+      <input type="submit" value="Submit"/>
+      
+    </ft:form-template>
+  </content>
+</page>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/binding/04heavy-bind.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/binding/04heavy-bind.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/binding/04heavy-bind.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/binding/04heavy-bind.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding" 
+            xmlns:fd="http://apache.org/cocoon/forms/1.0#definition" 
+	    path="/" >
+
+  <fb:repeater id="outer"
+               parent-path="/"
+               row-path="data">
+    <fb:identity>
+      <fb:value id="id" path="@id">
+        <fd:convertor datatype="integer"/>
+      </fb:value>
+    </fb:identity>
+    <fb:on-bind>
+
+      <fb:repeater id="inner"
+                   parent-path="/"
+                   row-path="data">
+        <fb:identity>
+          <fb:value id="id" path="@id">
+            <fd:convertor datatype="integer"/>
+          </fb:value>
+        </fb:identity>
+
+        <fb:on-bind>
+        </fb:on-bind>
+      </fb:repeater>
+
+    </fb:on-bind>
+  </fb:repeater>
+
+</fb:context>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/binding/04heavy-data.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/binding/04heavy-data.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/binding/04heavy-data.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/binding/04heavy-data.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<root>     
+  <data id="1"/>
+  <data id="2"/>
+  <data id="3"/>
+  <data id="4"/>
+  <data id="5"/>
+  <data id="6"/>
+  <data id="7"/>
+  <data id="8"/>
+  <data id="9"/>
+  <data id="10"/>
+  <data id="11"/>
+  <data id="12"/>
+  <data id="13"/>
+  <data id="14"/>
+  <data id="15"/>
+<!--
+  <data id="16"/>
+  <data id="17"/>
+  <data id="18"/>
+  <data id="19"/>
+  <data id="20"/>
+  <data id="21"/>
+  <data id="22"/>
+  <data id="23"/>
+  <data id="24"/>
+  <data id="25"/>
+  <data id="26"/>
+  <data id="27"/>
+  <data id="28"/>
+  <data id="29"/>
+  <data id="30"/>
+-->
+</root>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/binding/04heavy-def.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/binding/04heavy-def.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/binding/04heavy-def.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/binding/04heavy-def.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">
+
+  <fd:widgets>
+    <fd:repeater id="outer">
+      <fd:widgets>
+        <fd:output id="id">
+          <fd:datatype base="integer"/>
+        </fd:output>
+
+        <fd:repeater id="inner">
+          <fd:widgets>
+            <fd:output id="id">
+              <fd:datatype base="integer"/>
+            </fd:output>
+
+            <fd:field id="select">
+              <fd:label>List</fd:label>
+              <fd:datatype base="integer"/>
+              <fd:selection-list>
+                <fd:item value="">
+                  <fd:label>Month</fd:label>
+                </fd:item>
+                <fd:item value="1">
+                  <fd:label>Jan</fd:label>
+                </fd:item>
+                <fd:item value="2">
+                  <fd:label>Feb</fd:label>
+                </fd:item>
+                <fd:item value="3">
+                  <fd:label>Mar</fd:label>
+                </fd:item>
+                <fd:item value="4">
+                  <fd:label>Apr</fd:label>
+                </fd:item>
+                <fd:item value="5">
+                  <fd:label>May</fd:label>
+                </fd:item>
+                <fd:item value="6">
+                  <fd:label>Jun</fd:label>
+                </fd:item>
+                <fd:item value="7">
+                  <fd:label>Jul</fd:label>
+                </fd:item>
+                <fd:item value="8">
+                  <fd:label>Aug</fd:label>
+                </fd:item>
+                <fd:item value="9">
+                  <fd:label>Sep</fd:label>
+                </fd:item>
+                <fd:item value="10">
+                  <fd:label>Oct</fd:label>
+                </fd:item>
+                <fd:item value="11">
+                  <fd:label>Nov</fd:label>
+                </fd:item>
+                <fd:item value="12">
+                  <fd:label>Dec</fd:label>
+                </fd:item>
+              </fd:selection-list>
+            </fd:field>
+
+          </fd:widgets>
+        </fd:repeater>
+
+      </fd:widgets>
+    </fd:repeater>
+
+  </fd:widgets>
+
+</fd:form>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/binding/04heavy-template.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/binding/04heavy-template.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/binding/04heavy-template.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/binding/04heavy-template.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<page xmlns:ft="http://apache.org/cocoon/forms/1.0#template" 
+      xmlns:fi="http://apache.org/cocoon/forms/1.0#instance" 
+      xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+  <title>Heavy Form</title>
+  <content>
+    <h3>Lots of select boxes</h3>
+
+    <ft:form-template>
+      <div>
+        <ft:repeater-widget id="outer">
+        <fi:group>
+          <fi:styling type="fieldset" style="border: 2px solid gray; float: left;" layout="columns" />
+          <fi:label>Group <ft:widget id="id"/></fi:label>
+          <fi:items>
+              <ft:repeater-widget id="inner">
+                <ft:widget id="select"/>
+              </ft:repeater-widget>
+          </fi:items>
+        </fi:group>
+        </ft:repeater-widget>
+      </div>
+
+      <p style="float: left; clear: both;">
+        <input type="submit" value="Submit"/>
+      </p>
+    </ft:form-template>
+  </content>
+</page>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/binding/05custom-bind.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/binding/05custom-bind.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/binding/05custom-bind.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/binding/05custom-bind.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding" 
+            xmlns:fd="http://apache.org/cocoon/forms/1.0#definition" 
+	    path="/" >
+
+  <!--+ 
+      | This file shows a sample of using the javascript binding. 
+      +-->
+  <fb:javascript id="jswrap" path="jswrap-value" >
+    <fb:save-form>
+      var formValue = widget.getValue();
+      // you can call a function from anywhere in the flowscript
+      var appValue = doSaveConversion(formValue, "-");
+      jxpathPointer.setValue(appValue);   
+    </fb:save-form>
+    <fb:load-form>
+      var appValue = jxpathPointer.getValue();
+      // you can call a function from anywhere in the flowscript
+      var formValue = doLoadConversion(appValue, "-");
+      widget.setValue(formValue);
+    </fb:load-form>
+  </fb:javascript>
+
+  <fb:custom id="custom" path="custom-value" 
+      class="org.apache.cocoon.forms.samples.bindings.CustomValueWrapBinding"/>
+  
+  <fb:custom id="config" path="config-value" 
+      builderclass="org.apache.cocoon.forms.samples.bindings.CustomValueWrapBinding"
+      factorymethod="createBinding" >
+      <fb:config prefixchar="[" suffixchar="]" />      
+  </fb:custom>
+
+</fb:context>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/binding/05custom-data.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/binding/05custom-data.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/binding/05custom-data.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/binding/05custom-data.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<root>     
+  <jswrap-value>--something--</jswrap-value>
+  <custom-value>**something more**</custom-value>
+  <config-value>[[something else]]</config-value>
+</root>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/binding/05custom-def.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/binding/05custom-def.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/binding/05custom-def.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/binding/05custom-def.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">
+
+  <fd:widgets>
+  
+    <fd:field id="jswrap" >
+      <fd:label>1st Value</fd:label>
+      <fd:datatype base="string" />
+    </fd:field>
+
+    <fd:field id="custom" >
+      <fd:label>2nd Value</fd:label>
+      <fd:datatype base="string" />
+    </fd:field>
+    
+    <fd:field id="config" >
+      <fd:label>3rd Value</fd:label>
+      <fd:datatype base="string" />
+    </fd:field>
+    
+  </fd:widgets>
+  
+</fd:form>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/binding/06namespaced-bind.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/binding/06namespaced-bind.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/binding/06namespaced-bind.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/binding/06namespaced-bind.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding" 
+            xmlns:fd="http://apache.org/cocoon/forms/1.0#definition" 
+            xmlns:h="http://www.w3.org/1999/xhtml"
+	    path="/" >
+
+<!-- 
+   | This file binds form data to a namespaced XML
+   -->
+   
+  <fb:context path="h:html/h:head" >
+    <fb:value id="title" path="html:title" lenient="true" />
+  </fb:context>
+            
+  <fb:context path="x:stylesheet" xmlns:x="http://www.w3.org/1999/XSL/Transform">
+    <fb:value id="template" path="x:template/@name" lenient="true"/>
+  </fb:context>
+            
+  <fb:context path="." xmlns:f="http://www.w3.org/1999/XSL/Format">
+    <fb:value id="flowname" path="f:root/f:page-sequence/f:flow/@flow-name" lenient="true"/>
+  </fb:context>
+
+</fb:context>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org