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/06/29 01:11:02 UTC

svn commit: r958780 - in /myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces: component/html/ext/AbstractHtmlDataTable.java custom/tree2/UITreeData.java

Author: lu4242
Date: Mon Jun 28 23:11:02 2010
New Revision: 958780

URL: http://svn.apache.org/viewvc?rev=958780&view=rev
Log:
MYFACES-2744 UIData.getClientId() should not append rowIndex, instead use UIData.getContainerClientId()

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/custom/tree2/UITreeData.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=958780&r1=958779&r2=958780&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 Mon Jun 28 23:11:02 2010
@@ -127,6 +127,7 @@ public abstract class AbstractHtmlDataTa
         return _tableContext;
     }
 
+    /*
     public String getClientId(FacesContext context)
     {
         String standardClientId = super.getClientId(context);
@@ -154,6 +155,36 @@ public abstract class AbstractHtmlDataTa
         //noinspection UnnecessaryLocalVariable
         String parsedForcedClientId = standardClientId.substring(0, indexLast_ + 1) + forcedIdIndex;
         return parsedForcedClientId;
+    }*/
+
+    @Override
+    public String getContainerClientId(FacesContext context)
+    {
+        String standardClientId = super.getContainerClientId(context);
+        int rowIndex = getRowIndex();
+        if (rowIndex == -1)
+        {
+            return standardClientId;
+        }
+
+        String forcedIdIndex = getForceIdIndexFormula();
+        if (forcedIdIndex == null || forcedIdIndex.length() == 0)
+            return standardClientId;
+
+        // Trick : Remove the last part starting with NamingContainer.SEPARATOR_CHAR that contains the rowIndex.
+        // It would be best to not resort to String manipulation,
+        // but we can't get super.super.getClientId() :-(
+        char separator = UINamingContainer.getSeparatorChar(context);
+        int indexLast_ = standardClientId.lastIndexOf(separator);
+        if (indexLast_ == -1)
+        {
+            log.info("Could not parse super.getClientId. forcedIdIndex will contain the rowIndex.");
+            return standardClientId + separator + forcedIdIndex;
+        }
+
+        //noinspection UnnecessaryLocalVariable
+        String parsedForcedClientId = standardClientId.substring(0, indexLast_ + 1) + forcedIdIndex;
+        return parsedForcedClientId;
     }
 
     public UIComponent findComponent(String expr)

Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/UITreeData.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/UITreeData.java?rev=958780&r1=958779&r2=958780&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/UITreeData.java (original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/UITreeData.java Mon Jun 28 23:11:02 2010
@@ -208,6 +208,7 @@ public class UITreeData extends UICompon
     }
 
     // see superclass for documentation
+    /*
     public String getClientId(FacesContext context)
     {
         String ownClientId = super.getClientId(context);
@@ -218,6 +219,19 @@ public class UITreeData extends UICompon
         {
             return ownClientId;
         }
+    }*/
+    
+    @Override
+    public String getContainerClientId(FacesContext context)
+    {
+        String ownClientId = super.getContainerClientId(context);
+        if (_nodeId != null)
+        {
+            return ownClientId + NamingContainer.SEPARATOR_CHAR + _nodeId;
+        } else
+        {
+            return ownClientId;
+        }
     }
 
     // see superclass for documentation