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 2014/02/13 22:34:35 UTC

svn commit: r1568044 - /myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounter.java

Author: lu4242
Date: Thu Feb 13 21:34:35 2014
New Revision: 1568044

URL: http://svn.apache.org/r1568044
Log:
MYFACES-3853 ui:include not working inside c:forEach

Modified:
    myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounter.java

Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounter.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounter.java?rev=1568044&r1=1568043&r2=1568044&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounter.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounter.java Thu Feb 13 21:34:35 2014
@@ -114,16 +114,17 @@ public class SectionUniqueIdCounter
     {
         //1. Calculate prefix
         _builder.delete(0, _builder.length());
-        boolean added = false;
-        for (int i = 0; i < _counterStack.size(); i++)
+        
+        if (!_counterStack.isEmpty())
         {
-            if (added)
+            String lastPrefix = _counterStack.get(_counterStack.size()-1).getPrefix();
+            if (lastPrefix != null)
             {
+                _builder.append(lastPrefix);
                 _builder.append('_');
             }
-            //_builder.append(Long.toString(_counterStack.get(i).getCounter(), _radix));
-            appendToBuilder(_counterStack.get(i).getCounter(), _radix, _builder, _bufferConversion);
-            added = true;
+            appendToBuilder(_counterStack.get(_counterStack.size()-1).getCounter(),
+                _radix, _builder, _bufferConversion);
         }
         
         _counterStack.add(new Section(_builder.toString(),1,_radix));
@@ -135,17 +136,19 @@ public class SectionUniqueIdCounter
     {
         //1. Calculate prefix
         _builder.delete(0, _builder.length());
-        boolean added = false;
-        for (int i = 0; i < _counterStack.size(); i++)
+        
+        if (!_counterStack.isEmpty())
         {
-            if (added)
+            String lastPrefix = _counterStack.get(_counterStack.size()-1).getPrefix();
+            if (lastPrefix != null)
             {
+                _builder.append(lastPrefix);
                 _builder.append('_');
             }
-            //_builder.append(Long.toString(_counterStack.get(i).getCounter(), _radix));
-            appendToBuilder(_counterStack.get(i).getCounter(), _radix, _builder, _bufferConversion);
-            added = true;
+            appendToBuilder(_counterStack.get(_counterStack.size()-1).getCounter(),
+                _radix, _builder, _bufferConversion);
         }
+
         if (base != null && base.length() > 0)
         {
             _builder.append('_');
@@ -202,6 +205,19 @@ public class SectionUniqueIdCounter
         }
     }
     
+    public void endUniqueIdSection(String base)
+    {
+        if (_activeSection <= 0)
+        {
+            return;
+        }
+        else
+        {
+            _counterStack.remove(_activeSection);
+            _activeSection--;
+        }
+    }
+    
     private static class Section
     {
         
@@ -272,6 +288,14 @@ public class SectionUniqueIdCounter
             appendToBuilder(i, _radix, _builder, _bufferConversion);
             return _builder.toString();
         }
+
+        /**
+         * @return the prefix
+         */
+        public String getPrefix()
+        {
+            return prefix;
+        }
     }
     
     //From Harmony Long.toString(l,radix)