cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jer...@apache.org
Subject svn commit: r160578 - in cocoon/blocks/core/forms/trunk: java/org/apache/cocoon/forms/flow/javascript/Form.js samples/sitemap.xmap
Date Fri, 08 Apr 2005 18:33:00 GMT
Author: jeremy
Date: Fri Apr  8 11:32:59 2005
New Revision: 160578

URL: http://svn.apache.org/viewcvs?view=rev&rev=160578
Log:
rationalising names of parameters to handleForm function

Modified:
    cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/flow/javascript/Form.js
    cocoon/blocks/core/forms/trunk/samples/sitemap.xmap

Modified: cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/flow/javascript/Form.js
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/flow/javascript/Form.js?view=diff&r1=160577&r2=160578
==============================================================================
--- cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/flow/javascript/Form.js (original)
+++ cocoon/blocks/core/forms/trunk/java/org/apache/cocoon/forms/flow/javascript/Form.js Fri
Apr  8 11:32:59 2005
@@ -244,24 +244,32 @@
 }
 
 function handleForm() {
-    var form = new Form(cocoon.parameters["form-definition"]);
-
-    var args = [form];
-
-    // set the binding on the form if there's any
+    // get the form definition
+    var def = cocoon.parameters["definitionURI"];
+    if (def == null) {
+        if (cocoon.parameters["form-definition"] != null) {
+            cocoon.log.warn("the form-definition parameter in handleForm has changed to definitionURI");
+            def = cocoon.parameters["form-definition"];
+        } else {
+            throw "Definition not configured for this form.";
+        }
+    }
+    // create the Form
+    var form = new Form(def);
+    // set the binding on the form if there is one
     var bindingURI = cocoon.parameters["bindingURI"];
     if (bindingURI != null) {
         form.createBinding(bindingURI);
     }
-
+    // get the function to call to handle the form
     var funcName = cocoon.parameters["function"];
     var func = this[funcName];
-
+    // check the function exists
     if (!func) {
         throw "Function \"" + funcName + "\" is not defined.";
     } else if (!(func instanceof Function)) {
         throw "\"" + funcName + "\" is not a function.";
     }
-
-    func.apply(this, args);
+    // call the function
+    func.apply(this, [form]);
 }

Modified: cocoon/blocks/core/forms/trunk/samples/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core/forms/trunk/samples/sitemap.xmap?view=diff&r1=160577&r2=160578
==============================================================================
--- cocoon/blocks/core/forms/trunk/samples/sitemap.xmap (original)
+++ cocoon/blocks/core/forms/trunk/samples/sitemap.xmap Fri Apr  8 11:32:59 2005
@@ -149,7 +149,7 @@
      <map:match pattern="form1.flow">
        <map:call function="handleForm">
          <map:parameter name="function" value="form1"/>
-         <map:parameter name="form-definition" value="forms/form1.xml"/>
+         <map:parameter name="definitionURI" value="forms/form1.xml"/>
        </map:call>
      </map:match>
 
@@ -239,7 +239,7 @@
      <map:match pattern="form2xml.flow">
        <map:call function="handleForm">
          <map:parameter name="function" value="form2xml"/>
-         <map:parameter name="form-definition" value="forms/form2_model.xml"/>
+         <map:parameter name="definitionURI" value="forms/form2_model.xml"/>
          <map:parameter name="documentURI" value="forms/form2_data.xml"/>
          <map:parameter name="bindingURI" value="forms/form2_bind_xml.xml"/>
        </map:call>
@@ -248,7 +248,7 @@
      <map:match pattern="form2simpleXML.flow">
        <map:call function="handleForm">
          <map:parameter name="function" value="form2simpleXML"/>
-         <map:parameter name="form-definition" value="forms/form2_model.xml"/>
+         <map:parameter name="definitionURI" value="forms/form2_model.xml"/>
          <map:parameter name="documentURI" value="forms/form2_simple_data.xml"/>
        </map:call>
      </map:match>
@@ -256,7 +256,7 @@
      <map:match pattern="form2bean.flow">
        <map:call function="handleForm">
          <map:parameter name="function" value="form2bean"/>
-         <map:parameter name="form-definition" value="forms/form2_model.xml"/>
+         <map:parameter name="definitionURI" value="forms/form2_model.xml"/>
          <map:parameter name="bindingURI" value="forms/form2_bind_bean.xml"/>
        </map:call>
      </map:match>
@@ -442,7 +442,7 @@
      <map:match pattern="form_model_gui.flow">
        <map:call function="handleForm">
          <map:parameter name="function" value="form_model_gui"/>
-         <map:parameter name="form-definition" value="forms/form_model_gui_model.xml"/>
+         <map:parameter name="definitionURI" value="forms/form_model_gui_model.xml"/>
          <map:parameter name="attribute-name" value="form_model_gui"/>
          <map:parameter name="documentURI" value="forms/form_model_gui_data.xml"/>
          <map:parameter name="bindingURI" value="forms/form_model_gui_binding.xml"/>



Mime
View raw message