You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/08/28 21:05:17 UTC

svn commit: r990409 - in /myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext: AbstractHtmlDataTable.java HtmlDataTableHack.java

Author: lu4242
Date: Sat Aug 28 19:05:16 2010
New Revision: 990409

URL: http://svn.apache.org/viewvc?rev=990409&view=rev
Log:
TOMAHAWK-1541 detailStamp state should be deleted on deleteRowStateForRow in t:dataTable

Modified:
    myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/AbstractHtmlDataTable.java
    myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTableHack.java

Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/AbstractHtmlDataTable.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/AbstractHtmlDataTable.java?rev=990409&r1=990408&r2=990409&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/AbstractHtmlDataTable.java (original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/AbstractHtmlDataTable.java Sat Aug 28 19:05:16 2010
@@ -597,6 +597,78 @@ public abstract class AbstractHtmlDataTa
         }
         return saveFullDescendantComponentStates(facesContext, null, getChildren().iterator(), false, getContainerClientId(facesContext));
     }
+    
+    @Override
+    public void deleteRowStateForRow(int deletedIndex)
+    {
+        super.deleteRowStateForRow(deletedIndex);
+
+        if (getFacetCount() > 0)
+        {
+            UIComponent detailStampFacet = getFacet(DETAIL_STAMP_FACET_NAME); 
+            if (detailStampFacet != null)
+            {
+                // save row index
+                int savedRowIndex = getRowIndex();
+                
+                FacesContext facesContext = getFacesContext();
+                setRowIndex(deletedIndex);
+                String currentRowStateKey = getContainerClientId(facesContext);
+        
+                int rowCount = getRowCount();
+                if (isPreserveRowComponentState())
+                {
+                    for (int index = deletedIndex + 1; index < rowCount; ++index)
+                    {
+                        setRowIndex(index);
+                        String nextRowStateKey = getContainerClientId(facesContext);
+            
+                        Object nextRowState = _detailRowStates.get(nextRowStateKey);
+                        if (nextRowState == null)
+                        {
+                            _detailRowStates.remove(currentRowStateKey);
+                        }
+                        else
+                        {
+                            _detailRowStates.put(currentRowStateKey, nextRowState);
+                        }
+                        currentRowStateKey = nextRowStateKey;
+                    }
+                    
+                    // restore saved row index
+                    setRowIndex(savedRowIndex);
+            
+                    // Remove last row
+                    _detailRowStates.remove(currentRowStateKey);
+                }
+                else
+                {
+                    for (int index = deletedIndex + 1; index < rowCount; ++index)
+                    {
+                        setRowIndex(index);
+                        String nextRowStateKey = getContainerClientId(facesContext);
+            
+                        Object nextRowState = _detailRowStates.get(nextRowStateKey);
+                        if (nextRowState == null)
+                        {
+                            _detailRowStates.remove(currentRowStateKey);
+                        }
+                        else
+                        {
+                            _detailRowStates.put(currentRowStateKey, nextRowState);
+                        }
+                        currentRowStateKey = nextRowStateKey;
+                    }
+                    
+                    // restore saved row index
+                    setRowIndex(savedRowIndex);
+            
+                    // Remove last row
+                    _detailRowStates.remove(currentRowStateKey);
+                }
+            }
+        }
+    }
 
     public void processDecodes(FacesContext context)
     {

Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTableHack.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTableHack.java?rev=990409&r1=990408&r2=990409&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTableHack.java (original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTableHack.java Sat Aug 28 19:05:16 2010
@@ -1107,7 +1107,7 @@ public abstract class HtmlDataTableHack 
         // save row index
         int savedRowIndex = getRowIndex();
         
-        FacesContext facesContext = FacesContext.getCurrentInstance();
+        FacesContext facesContext = getFacesContext();
          setRowIndex(deletedIndex);
         String currentRowStateKey = getContainerClientId(facesContext);
 
@@ -1131,6 +1131,9 @@ public abstract class HtmlDataTableHack 
                 }
                 currentRowStateKey = nextRowStateKey;
             }
+
+            // restore saved row index
+            setRowIndex(savedRowIndex);
     
             // Remove last row
             _rowDeltaStates.remove(currentRowStateKey);
@@ -1153,13 +1156,13 @@ public abstract class HtmlDataTableHack 
                 }
                 currentRowStateKey = nextRowStateKey;
             }
+
+            // restore saved row index
+            setRowIndex(savedRowIndex);
     
             // Remove last row
             _rowStates.remove(currentRowStateKey);
         }
-
-        // restore saved row index
-        setRowIndex(savedRowIndex);
     }