myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1138533 - 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/
Date Wed, 22 Jun 2011 16:19:23 GMT
Author: lu4242
Date: Wed Jun 22 16:19:23 2011
New Revision: 1138533

URL: http://svn.apache.org/viewvc?rev=1138533&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_offset.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=1138533&r1=1138532&r2=1138533&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 22 16:19:23 2011
@@ -544,13 +544,13 @@ public class UIRepeat extends UIComponen
                     "than zero");
             }
             
-            else if (size > end) {
+            else if ((begin + size) > end) {
                 throw new FacesException ("iteration size cannot be greater " +
                     "than collection size");
             }
         }
         
-        if ((size > -1) && (begin > size)) {
+        if ((size > -1) && (begin > end)) {
             throw new FacesException ("iteration offset 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=1138533&r1=1138532&r2=1138533&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 22 16:19:23 2011
@@ -323,4 +323,21 @@ public class RepeatTestCase extends Face
         
     }
     
+    
+    @Test
+    public void testRepeatOffset() 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_offset.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_offset.xhtml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/ui_repeat_offset.xhtml?rev=1138533&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/ui_repeat_offset.xhtml
(added)
+++ myfaces/core/trunk/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/ui_repeat_offset.xhtml
Wed Jun 22 16:19:23 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" size="1" >
+            <h:outputText id="outputText" value="#{row}" />
+        </ui:repeat>
+    </h:form>
+</body>
+</html>



Mime
View raw message