Hi,

I have a setup where I have my form definition in a DOM Element. I used to load Forms.js version 2, because that script did cover this need. But now I need to pass some bizdata and it seems like this was missed out in version 2.

Besides this, I've heard that there are plans to review Forms.js and remove the other versions (or merge the interesting parts together).

Momentarily I've patched my version of Forms.js to be able to create a form starting from a DOM Element and combine this with the functionality of version 1. (I actually grabbed a piece of version 2 and fitted it into version 1 with a bit glueing) This may not be much, but it does have more potential than the normal v1.

I hope this can be integrated with the next (final?) Form version as this might be usefull for others as well. I've created a diff patch on the svn branch checked out today as described on http://cocoon.apache.org/community/contrib.html and attached it to this mail.

Do I create an issue for this (haven't used bugzilla before)?

Kind Regards,
Jan



Index: Form.js
===================================================================
--- Form.js     (revision 124187)
+++ Form.js     (working copy)
@@ -27,16 +27,23 @@
 /**
  * Create a form, given the URI of its definition file
  */
-function Form(uri) {
+function Form(formDefinition) {
     var formMgr = null;
     var resolver = null;
     var src = null;
     var xmlAdapter = null;
     try {
         formMgr = 
cocoon.getComponent(Packages.org.apache.cocoon.forms.FormManager.ROLE);
-        resolver = 
cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
-        src = resolver.resolveURI(uri);
-        this.form = formMgr.createForm(src);
+        if ((typeof formDefinition) == "string" || formDefinition instanceof 
String) 
+        {
+               resolver = 
cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
+                   src = resolver.resolveURI(formDefinition);
+               this.form = formMgr.createForm(src);
+       }
+       else
+       {
+               this.form = formMgr.createForm(formDefinition);
+       }
         this.binding = null;
         this.eventHandler = null;
         // FIXME : hack needed because FOM doesn't provide access to the 
context
@@ -47,7 +54,7 @@
     } finally {
         cocoon.releaseComponent(formMgr);
         if (src != null) resolver.release(src);
-        cocoon.releaseComponent(resolver);
+        if (resolver != null) cocoon.releaseComponent(resolver);
     }
 }
 

Reply via email to