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/22 18:19:02 UTC
svn commit: r1138532 - in /myfaces/core/branches/2.0.x/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 22 16:19:02 2011
New Revision: 1138532
URL: http://svn.apache.org/viewvc?rev=1138532&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_offset.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=1138532&r1=1138531&r2=1138532&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 22 16:19:02 2011
@@ -541,13 +541,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/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=1138532&r1=1138531&r2=1138532&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 22 16:19:02 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/branches/2.0.x/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/ui_repeat_offset.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_offset.xhtml?rev=1138532&view=auto
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/ui_repeat_offset.xhtml (added)
+++ myfaces/core/branches/2.0.x/impl/src/test/resources/org/apache/myfaces/view/facelets/tag/ui/ui_repeat_offset.xhtml Wed Jun 22 16:19:02 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>