-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 20 Jul 2005, Antonio Gallardo wrote:

Date: Wed, 20 Jul 2005 09:37:26 -0500
From: Antonio Gallardo <[EMAIL PROTECTED]>
Reply-To: [email protected]
To: [email protected]
Subject: Re: svn commit: r219856 - in
    /cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/form
    s: binding/MultiValueJXPathBinding.java
    flow/javascript/ScriptableWidget.java

Hi Giacomo,

I guess it is related to commons-jxpath-1.2. Can you add the buggy version number of the JXPath lib? This could help in the future to check if this bug is already fixed on the released jars? If there is already a bug for this in JXPath, will be fine to add the bug # in the comment.

I've tried to add a bug to bugzilla for commons-jxpath but connection here at ApacheCon has prevented me until now. But sure it's still on my todo list :-)

Thanks

Giacomo


Best Regards,

Antonio Gallardo

[EMAIL PROTECTED] wrote:

Author: giacomo
Date: Wed Jul 20 01:19:35 2005
New Revision: 219856

URL: http://svn.apache.org/viewcvs?rev=219856&view=rev
Log:
added workaround for a bug in commons-jxpath's JXPathContext.removeAll(path) which isn't really removing all elements from a Collection type object

Modified:
    
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/MultiValueJXPathBinding.java
    
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/ScriptableWidget.java

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/MultiValueJXPathBinding.java URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/MultiValueJXPathBinding.java?rev=219856&r1=219855&r2=219856&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/MultiValueJXPathBinding.java (original) +++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/MultiValueJXPathBinding.java Wed Jul 20 01:19:35 2005
@@ -15,8 +15,11 @@
 */
 package org.apache.cocoon.forms.binding;

+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.LinkedList;
+import java.util.List;
 import java.util.Locale;

 import org.apache.avalon.framework.logger.Logger;
@@ -104,7 +107,23 @@
         JXPathContext multiValueContext =
         jctx.getRelativeContext(jctx.createPath(this.multiValuePath));

         // Delete all that is already present
-        multiValueContext.removeAll(this.rowPath);
+ + // Unfortunately the following statement doesn't work (it doesn't removes all elements from the + // list because of a bug in JXPath) so I had to work out another immediate solution
+        //multiValueContext.removeAll(this.rowPath);
+ + Iterator rowPointers = multiValueContext.iteratePointers(this.rowPath);
+        List l = new ArrayList();
+        while( rowPointers.hasNext() )
+        {
+            Pointer p = (Pointer)rowPointers.next();
+            l.add(p.asPath());
+        }
+        Collections.sort(l);
+        for( int i = l.size()-1; i >= 0; i-- )
+        {
+            multiValueContext.removePath((String)l.get(i));
+        }

         boolean update = false;


Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/ScriptableWidget.java URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/ScriptableWidget.java?rev=219856&r1=219855&r2=219856&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/ScriptableWidget.java (original) +++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/ScriptableWidget.java Wed Jul 20 01:19:35 2005
@@ -30,6 +30,8 @@
 import org.mozilla.javascript.Undefined;
 import org.mozilla.javascript.Wrapper;

+import java.util.Collection;
+
 /**
  * @version $Id$
* @@ -256,6 +258,8 @@
                     }
                 } else if (value instanceof Object[]) {
                     values = (Object[])value;
+                } else if (value instanceof Collection ) {
+                    values = ((Collection)value).toArray();
                 }
                 field.setValues(values);
             } else {






- -- Giacomo Pati
Otego AG, Switzerland - http://www.otego.com
Orixo, the XML business alliance - http://www.orixo.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFC32jhLNdJvZjjVZARAn24AJ4496e8QKhBIL5yM0pSNv65eSx3lgCfc1mE
9I+v2m/xbvP8DFj1UcmOZ7Q=
=wsmV
-----END PGP SIGNATURE-----

Reply via email to