Author: lu4242 Date: Wed Jun 29 21:29:10 2011 New Revision: 1141259 URL: http://svn.apache.org/viewvc?rev=1141259&view=rev Log: MYFACES-3034 ui:repeat offset and size performs incorrect validation Added: myfaces/core/branches/2.0.x/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/ui_repeat_offset2.xhtml Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/RepeatTestCase.java Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java?rev=1141259&r1=1141258&r2=1141259&view=diff ============================================================================== --- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java (original) +++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/view/facelets/component/UIRepeat.java Wed Jun 29 21:29:10 2011 @@ -532,9 +532,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) { @@ -543,7 +545,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/branches/2.0.x/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/RepeatTestCase.java URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/RepeatTestCase.java?rev=1141259&r1=1141258&r2=1141259&view=diff ============================================================================== --- myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/RepeatTestCase.java (original) +++ myfaces/core/branches/2.0.x/impl/src/test/java/org/apache/myfaces/view/facelets/tag/ui/RepeatTestCase.java Wed Jun 29 21:29:10 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/branches/2.0.x/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/ui_repeat_offset2.xhtml URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/ui_repeat_offset2.xhtml?rev=1141259&view=auto ============================================================================== --- myfaces/core/branches/2.0.x/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/ui_repeat_offset2.xhtml (added) +++ myfaces/core/branches/2.0.x/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/ui_repeat_offset2.xhtml Wed Jun 29 21:29:10 2011 @@ -0,0 +1,28 @@ + + + + + + + + + + + + +