myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1568050 - in /myfaces/core/trunk/impl/src: main/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounter.java test/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounterTest.java
Date Thu, 13 Feb 2014 21:47:34 GMT
Author: lu4242
Date: Thu Feb 13 21:47:34 2014
New Revision: 1568050

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

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounter.java
    myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounterTest.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounter.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounter.java?rev=1568050&r1=1568049&r2=1568050&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounter.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounter.java
Thu Feb 13 21:47:34 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('_');
@@ -285,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)

Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounterTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounterTest.java?rev=1568050&r1=1568049&r2=1568050&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounterTest.java
(original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/impl/SectionUniqueIdCounterTest.java
Thu Feb 13 21:47:34 2014
@@ -157,4 +157,28 @@ public class SectionUniqueIdCounterTest 
         Assert.assertEquals(counterOrig.generateUniqueId(), counter.generateUniqueId());
     }
     
+    @Test
+    public void testCounterExpansion()
+    {
+        SectionUniqueIdCounter counter = new SectionUniqueIdCounter();
+        
+        Assert.assertEquals("1", counter.generateUniqueId());
+        Assert.assertEquals("2", counter.generateUniqueId());
+        Assert.assertEquals("3_X", counter.startUniqueIdSection("X"));
+        Assert.assertEquals("3_X_1", counter.generateUniqueId());
+        Assert.assertEquals("3_X_2",counter.generateUniqueId());
+        Assert.assertEquals("3_X_3",counter.startUniqueIdSection());
+        Assert.assertEquals("3_X_3_1",counter.generateUniqueId());
+        Assert.assertEquals("3_X_3_2",counter.generateUniqueId());
+        counter.endUniqueIdSection();
+        Assert.assertEquals("3_X_4",counter.generateUniqueId());
+        counter.endUniqueIdSection("X");
+        Assert.assertEquals("3_Y", counter.startUniqueIdSection("Y"));
+        Assert.assertEquals("3_Y_1", counter.generateUniqueId());
+        counter.endUniqueIdSection("Y");
+        Assert.assertEquals("3", counter.generateUniqueId());
+        Assert.assertEquals("4", counter.generateUniqueId());
+    }
+    
+    
 }



Mime
View raw message