cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject svn commit: r601839 - in /cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding: EnhancedRepeaterJXPathBinding.java RepeaterJXPathBinding.java
Date Thu, 06 Dec 2007 20:05:25 GMT
Author: antonio
Date: Thu Dec  6 12:05:24 2007
New Revision: 601839

URL: http://svn.apache.org/viewvc?rev=601839&view=rev
Log:
Paginated repeater should work with binding identities if they are available.

Modified:
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/EnhancedRepeaterJXPathBinding.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/RepeaterJXPathBinding.java

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/EnhancedRepeaterJXPathBinding.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/EnhancedRepeaterJXPathBinding.java?rev=601839&r1=601838&r2=601839&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/EnhancedRepeaterJXPathBinding.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/EnhancedRepeaterJXPathBinding.java
Thu Dec  6 12:05:24 2007
@@ -17,6 +17,7 @@
 package org.apache.cocoon.forms.binding;
 
 import java.util.Iterator;
+import java.util.List;
 
 import org.apache.avalon.framework.CascadingRuntimeException;
 
@@ -25,6 +26,7 @@
 import org.apache.cocoon.forms.formmodel.Repeater;
 import org.apache.cocoon.forms.formmodel.Widget;
 
+import org.apache.commons.collections.ListUtils;
 import org.apache.commons.jxpath.JXPathContext;
 import org.apache.commons.jxpath.Pointer;
 
@@ -91,7 +93,24 @@
         // iterate updated rows. note: we don't iterate over the whole context
         for (Iterator iter = collection.getUpdatedRows().iterator(); iter.hasNext();) {
             RepeaterItem item = (RepeaterItem) iter.next();
-            getRowBinding().saveFormToModel(item.getRow(), item.getContext());
+            Repeater.RepeaterRow thisRow = item.getRow();
+            // Get the identity
+            List identity = getIdentity(thisRow);
+            if (hasNonNullElements(identity)) {
+                 // iterate nodes to find match
+                Iterator rowPointers = repeaterContext.iteratePointers(getRowPath());
+                while (rowPointers.hasNext()) {
+                    Pointer jxp = (Pointer) rowPointers.next();
+                    JXPathContext rowContext = repeaterContext.getRelativeContext(jxp);
+                    List contextIdentity = getIdentity(rowContext);
+                    if (ListUtils.isEqualList(identity, contextIdentity)) {
+                        getRowBinding().saveFormToModel(thisRow, rowContext);
+                        break;
+                    }
+                }
+            } else {
+                getRowBinding().saveFormToModel(thisRow, item.getContext().getContextPointer());
+            }
         }
 
         for (Iterator iter = collection.getDeletedRows().iterator(); iter.hasNext();) {

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/RepeaterJXPathBinding.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/RepeaterJXPathBinding.java?rev=601839&r1=601838&r2=601839&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/RepeaterJXPathBinding.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/binding/RepeaterJXPathBinding.java
Thu Dec  6 12:05:24 2007
@@ -315,7 +315,7 @@
      * Tests if any of the elements in a List is not null.
      * @param list
      */
-    private boolean hasNonNullElements(List list) {
+    protected boolean hasNonNullElements(List list) {
         Iterator iter = list.iterator();
         while (iter.hasNext()) {
             if (iter.next() != null) {
@@ -331,7 +331,7 @@
      * @param rowContext
      * @return List the identity of the row context
      */
-    private List getIdentity(JXPathContext rowContext) {
+    protected List getIdentity(JXPathContext rowContext) {
         List identity = Collections.EMPTY_LIST;
         if (this.identityBinding != null) {
             JXPathBindingBase[] childBindings = this.identityBinding.getChildBindings();
@@ -370,7 +370,7 @@
      * @param row
      * @return List the identity of the row
      */
-    private List getIdentity(Repeater.RepeaterRow row) {
+    protected List getIdentity(Repeater.RepeaterRow row) {
         // quit if we don't have an identity binding
         List identity = Collections.EMPTY_LIST;
         if (this.identityBinding != null) {



Mime
View raw message