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/07/15 04:04:11 UTC

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

Author: lu4242
Date: Thu Jul 15 02:04:11 2010
New Revision: 964279

URL: http://svn.apache.org/viewvc?rev=964279&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/HtmlDataTableHack.java

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=964279&r1=964278&r2=964279&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 Jul 15 02:04:11 2010
@@ -42,6 +42,7 @@ import javax.faces.model.ResultSetDataMo
 import javax.faces.model.ScalarDataModel;
 import javax.servlet.jsp.jstl.sql.Result;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.myfaces.component.html.util.HtmlComponentUtils;
 import org.apache.myfaces.custom.ExtendedComponentBase;
 
@@ -113,6 +114,23 @@ public abstract class HtmlDataTableHack 
         if (clientId == null)
         {
             clientId = super.getClientId(context);
+            // remove index if necesssary 
+            int rowIndex = getRowIndex();
+            if (rowIndex != -1)
+            {
+                char separator = UINamingContainer.getSeparatorChar(context);
+                int index = clientId.lastIndexOf(separator);
+                if(index != -1)
+                {
+                    String rowIndexString = clientId.substring(index + 1);
+                    if (rowIndexString.length() > 0 && 
+                        StringUtils.isNumeric(rowIndexString) &&
+                        rowIndex == Integer.valueOf(rowIndexString).intValue())
+                    {
+                        clientId = clientId.substring(0,index - 1);
+                    }
+                }
+            }
         }
         return clientId;
     }
@@ -124,7 +142,7 @@ public abstract class HtmlDataTableHack 
         String clientId = HtmlComponentUtils.getClientId(this, getRenderer(context), context);
         if (clientId == null)
         {
-            clientId = super.getContainerClientId(context);
+            clientId = super.getClientId(context);
         }
         int rowIndex = getRowIndex();
         if (rowIndex == -1)
@@ -137,16 +155,11 @@ public abstract class HtmlDataTableHack 
         if(index != -1)
         {
             String rowIndexString = clientId.substring(index + 1);
-            try
-            {
-                if(Integer.parseInt(rowIndexString) == rowIndex)
-                {
-                    return clientId;
-                }
-            }
-            catch(NumberFormatException e)
+            if(rowIndexString.length() > 0 && 
+               StringUtils.isNumeric(rowIndexString) &&
+               Integer.valueOf(rowIndexString) == rowIndex)
             {
-                return clientId + separator + rowIndex;
+                return clientId;
             }
         }
         return clientId + separator + rowIndex;