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 2011/06/29 23:29:35 UTC

svn commit: r1141260 - in /myfaces/core/trunk/impl/src: main/java/org/apache/myfaces/view/facelets/component/ test/java/org/apache/myfaces/view/facelets/tag/ui/ test/resources/org/apache/myfaces/view/facelets/tag/ui/

Author: lu4242
Date: Wed Jun 29 21:29:35 2011
New Revision: 1141260

URL: http://svn.apache.org/viewvc?rev=1141260&view=rev
Log:
MYFACES-3034 ui:repeat offset and size performs incorrect validation

Added:
    myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/ui_repeat_offset2.xhtml
Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java
    myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/RepeatTestCase.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java?rev=1141260&r1=1141259&r2=1141260&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java Wed Jun 29 21:29:35 2011
@@ -535,9 +535,11 @@ public class UIRepeat extends UIComponen
         int end = getDataModel().getRowCount();
         int size = getSize();
         int step = getStep();
+        boolean sizeIsEnd = false;
         
         if (size == -1) {
             size = end;
+            sizeIsEnd = true;
         }
         
         if (end >= 0) {
@@ -546,7 +548,7 @@ public class UIRepeat extends UIComponen
                     "than zero");
             }
             
-            else if ((begin + size) > end) {
+            else if (!sizeIsEnd && (begin + size) > end) {
                 throw new FacesException ("iteration size cannot be greater " +
                     "than collection size");
             }

Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/RepeatTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/RepeatTestCase.java?rev=1141260&r1=1141259&r2=1141260&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/RepeatTestCase.java (original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/RepeatTestCase.java Wed Jun 29 21:29:35 2011
@@ -340,4 +340,21 @@ public class RepeatTestCase extends Face
         root.encodeAll(facesContext);
         //System.out.println(fw);
     }
+    
+    @Test
+    public void testRepeatOffset2() throws Exception 
+    {
+        final String[] repeatValues = new String[] {"B1", "B2", "B3", "B4", "B5", "B6", "B7"};
+        facesContext.getExternalContext().getRequestMap().put("repeatValues", repeatValues);
+        
+        UIViewRoot root = facesContext.getViewRoot();
+        vdl.buildView(facesContext, root, "ui_repeat_offset2.xhtml");
+        
+        FastWriter fw = new FastWriter();
+        ResponseWriter rw = facesContext.getResponseWriter();
+        rw = rw.cloneWithWriter(fw);
+        facesContext.setResponseWriter(rw);
+        root.encodeAll(facesContext);
+        //System.out.println(fw);
+    }
 }

Added: myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/ui_repeat_offset2.xhtml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/ui_repeat_offset2.xhtml?rev=1141260&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/ui_repeat_offset2.xhtml (added)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/ui_repeat_offset2.xhtml Wed Jun 29 21:29:35 2011
@@ -0,0 +1,28 @@
+<!--
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+	xmlns:h="http://java.sun.com/jsf/html"
+	xmlns:f="http://java.sun.com/jsf/core"
+	xmlns:ui="http://java.sun.com/jsf/facelets">
+<head>
+</head>
+<body>
+    <h:form id="form">
+        <ui:repeat id="repeat" value="#{repeatValues}" var="row" offset="2">
+            <h:outputText id="outputText" value="#{row}" />
+        </ui:repeat>
+    </h:form>
+</body>
+</html>