You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Thomas Timbul (JIRA)" <de...@myfaces.apache.org> on 2014/09/11 16:53:34 UTC

[jira] [Commented] (MYFACES-3034) ui:repeat offset and size performs incorrect validation

    [ https://issues.apache.org/jira/browse/MYFACES-3034?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14130106#comment-14130106 ] 

Thomas Timbul commented on MYFACES-3034:
----------------------------------------

I know this is old, but in the original facelets (JSF 1.2) it used to be possible to use the "size" attribute to restrict the iteration size to a "maximum" value. Take this scenario:

Collection size: 2
ui:repeat "size": 3

Without "offset" specified, a maximum of 3 items would be rendered, in this case 2.
After this "fix" (yea, I finally got to upgrade something after nearly 3 years!), this no longer works and requires some fairly ugly workarounds, such as adding a custom function:
{code:xml}
<ui:repeat value="#{coll}" size="#{c:max(coll.size(), 3)}">
{code}

As to why the spec would suggest that an exception be thrown when it would be dead simple to make the implementation tolerant is beyond me. But the original facelets WAS tolerant of setting a size larger than the actual collection. After all, why should the view know what the size of a collection is at runtime? The view should only be concerned with what the user interface will tolerate as a maximum...


> ui:repeat offset and size performs incorrect validation
> -------------------------------------------------------
>
>                 Key: MYFACES-3034
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3034
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 2.0.3
>         Environment: OpenJDK 1.6.0_20; Tomcat 6.0.20; Ubuntu 10.04 on kernel version 2.6.32-28-generic
>            Reporter: Rey Dalisay
>            Assignee: Leonardo Uribe
>             Fix For: 2.0.8, 2.1.2
>
>
> The following ui:repeat tag with those values of size and offset throw a FacesException with the message: "iteration offset cannot be greater than collection size."
> <ui:repeat var="listing" value="#{myListings.listings}" size="19" offset="20">
> It appears that the method _validateAttributes() in the UIRepeat class performs the validation incorrectly.  It seems to assume that the value of size is the size of the collection, rather than the desired iteration size.  Here is the relevant code from _validateAttributes():
>         if ((size > -1) && (begin > size)) {
>             throw new FacesException ("iteration offset cannot be greater " +
>                 "than collection size");
>         }
> The exception is thrown in the above case because begin > size, where begin = offset = 20.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)