myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1099868 - in /myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/component/html/ext: AbstractHtmlDataTable.java HtmlDataTableHack.java
Date Thu, 05 May 2011 16:39:45 GMT
Author: lu4242
Date: Thu May  5 16:39:45 2011
New Revision: 1099868

URL: http://svn.apache.org/viewvc?rev=1099868&view=rev
Log:
TOMAHAWK-1583 Add rowStatePreserved alias for preserveRowComponentState

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=1099868&r1=1099867&r2=1099868&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
Thu May  5 16:39:45 2011
@@ -1177,7 +1177,7 @@ public abstract class AbstractHtmlDataTa
     
     public void markInitialState()
     {
-        if (isPreserveRowComponentState())
+        if (isPreserveRowComponentState() || isRowStatePreserved())
         {
             if (getFacesContext().getAttributes().containsKey("javax.faces.view.ViewDeclarationLanguage.IS_BUILDING_INITIAL_STATE"))
             {

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=1099868&r1=1099867&r2=1099868&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
Thu May  5 16:39:45 2011
@@ -265,6 +265,30 @@ public abstract class HtmlDataTableHack 
         }
         return DEFAULT_PRESERVEROWSTATES;
     }
+    
+    /**
+     * Indicates whether the state for a component in each row should not be 
+     * discarded before the datatable is rendered again.
+     * 
+     * In tomahawk, this property is the same as t:dataTable preserveRowComponentState
+     * 
+     * This will only work reliable if the datamodel of the 
+     * datatable did not change either by sorting, removing or 
+     * adding rows. Default: false
+     * 
+     * @return
+     */
+    @JSFProperty(literalOnly=true, faceletsOnly=true, defaultValue="false")
+    public boolean isRowStatePreserved()
+    {
+        Boolean b = (Boolean) getStateHelper().get(PropertyKeys.rowStatePreserved);
+        return b == null ? false : b.booleanValue(); 
+    }
+    
+    public void setRowStatePreserved(boolean preserveComponentState)
+    {
+        getStateHelper().put(PropertyKeys.rowStatePreserved, preserveComponentState);
+    }
 
     protected boolean hasErrorMessages(FacesContext context)
     {
@@ -291,7 +315,7 @@ public abstract class HtmlDataTableHack 
     @SuppressWarnings("unchecked")
     public void setRowIndex(int rowIndex)
     {
-        if (isPreserveRowComponentState() && _initialDescendantFullComponentState
!= null)
+        if ( (isPreserveRowComponentState() || isRowStatePreserved()) && _initialDescendantFullComponentState
!= null)
         {
             setRowIndexPreserveComponentState(rowIndex);
         }
@@ -548,7 +572,7 @@ public abstract class HtmlDataTableHack 
     @Override
     public void markInitialState()
     {
-        if (isPreserveRowComponentState())
+        if (isPreserveRowComponentState() || isRowStatePreserved())
         {
             if (getFacesContext().getAttributes().containsKey("javax.faces.view.ViewDeclarationLanguage.IS_BUILDING_INITIAL_STATE"))
             {
@@ -1093,7 +1117,7 @@ public abstract class HtmlDataTableHack 
      */
     public void clearRowStates()
     {
-        if (isPreserveRowComponentState())
+        if (isPreserveRowComponentState() || isRowStatePreserved())
         {
             _rowDeltaStates.clear();
         }
@@ -1120,7 +1144,7 @@ public abstract class HtmlDataTableHack 
         if (rowKey != null)
         {
             setRowIndex(deletedIndex);
-            if (isPreserveRowComponentState())
+            if (isPreserveRowComponentState() || isRowStatePreserved())
             {
                 _rowDeltaStates.remove(currentRowStateKey);
             }
@@ -1134,7 +1158,7 @@ public abstract class HtmlDataTableHack 
         {
             // copy next rowstate to current row for each row from deleted row onward.
             int rowCount = getRowCount();
-            if (isPreserveRowComponentState())
+            if (isPreserveRowComponentState() || isRowStatePreserved())
             {
                 for (int index = deletedIndex + 1; index < rowCount; ++index)
                 {
@@ -1285,5 +1309,6 @@ public abstract class HtmlDataTableHack 
         , preserveRowComponentState
         , rowKey
         , derivedRowKeyPrefix
+        , rowStatePreserved
     }
 }



Mime
View raw message