You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by gi...@apache.org on 2005/07/20 10:19:37 UTC

svn commit: r219856 - in /cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms: binding/MultiValueJXPathBinding.java flow/javascript/ScriptableWidget.java

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 {



Re: svn commit: r219856 - in /cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms: binding/MultiValueJXPathBinding.java flow/javascript/ScriptableWidget.java

Posted by Giacomo Pati <gi...@apache.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, 21 Jul 2005, Giacomo Pati wrote:

> 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 :-)

After reestablishing network connection here at ApacheCon I was able to 
check the current commons-jxpath code base. It seem the bug is already 
fixed there. Is somebody on commons-jxpath ML and can answer when that 
code base gets released so that I can revert my workaround?

Ciao

Giacomo

>
> Thanks
>
> Giacomo
>
>>
>>  Best Regards,
>>
>>  Antonio Gallardo
>>
>>  giacomo@apache.org 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
> --[PinePGP]-----------------------------------------------------------
> gpg:  Signature made Thu Jul 21 11:20:33 2005 CEST using DSA key ID 98E35590
> gpg:  Good signature from "Giacomo Pati <gi...@apache.org>"
> gpg:                  aka "Giacomo Pati <gi...@otego.com>"
> --[PinePGP]----------------------------------------------------[end]--
>
>

- -- 
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)

iD8DBQFC33ykLNdJvZjjVZARAiL3AJ0U+PqUHsBCXTc1FLyRw8j/PjaBPACdGPFY
7oaXfe6Mor/C/nmIQQc3CC8=
=JN32
-----END PGP SIGNATURE-----

Re: svn commit: r219856 - in /cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms: binding/MultiValueJXPathBinding.java flow/javascript/ScriptableWidget.java

Posted by Giacomo Pati <gi...@apache.org>.
-----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 <ag...@agssa.net>
> Reply-To: dev@cocoon.apache.org
> To: dev@cocoon.apache.org
> 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
>
> giacomo@apache.org 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-----

Re: svn commit: r219856 - in /cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms: binding/MultiValueJXPathBinding.java flow/javascript/ScriptableWidget.java

Posted by Antonio Gallardo <ag...@agssa.net>.
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.

Best Regards,

Antonio Gallardo

giacomo@apache.org 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 {
>
>  
>