[
https://issues.apache.org/jira/browse/TRINIDAD-2245?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13233342#comment-13233342
]
Paresh Kumar Acharya edited comment on TRINIDAD-2245 at 3/20/12 10:50 AM:
--------------------------------------------------------------------------
The ArrayIndexOutOfBoundsException is thrown because the _currentEndIndex is
not updated correctly in the forEachTag.
To fix the issue used <= inplace of < in the comaprision which updates the
_currentEndIndex based on the size of the collection.
was (Author: pareshacharya):
To fix the issue the iterating the list is limited only up to the size of
the collection.
> ForEach tag throws ArrayIndexOfBoundsException when the end attribute is same
> as the size of the List
> -----------------------------------------------------------------------------------------------------
>
> Key: TRINIDAD-2245
> URL: https://issues.apache.org/jira/browse/TRINIDAD-2245
> Project: MyFaces Trinidad
> Issue Type: Bug
> Components: Components
> Affects Versions: 2.0.1-core
> Reporter: Paresh Kumar Acharya
> Attachments: ForEachTag_trunk.patch
>
>
> While iterating a collection using forEach Tag if the value specified using
> the end attribute matches the size of the collection
> ArrayIndexOutOfBoundsException is thrown.
> The Exception is not thrown if the end attribute is more than or less than
> the size of the list.
> The following sample code can be used to reproduce the bug.
> Ex:-
> Managed Bean:-
> ------------------------
> The Dept class depends on Employee class which just has one field named
> "name" with accessors.
> public class Dept {
> public Dept() {
> super();
> }
>
> public List getEmployees()
> {
> List employees = new ArrayList();
> for(int i=0;i<10;i++) {
> Employee emp = new Employee("Name "+i);
> employees.add(emp);
> }
> return employees;
> }
> }
>
>
> JSf code:-
> --------------
>
> <af:forEach begin="0" end="10" var="item"
> items="#{dept.employees}"
> varStatus="dd">
> <af:outputText
> value="(#{dd.index})--#{item['name']}--"
> inlineStyle="width:132px;
> font-weight:bold;" id="ot3"/>
> </af:forEach>
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira