You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Paresh Kumar Acharya (Created) (JIRA)" <de...@myfaces.apache.org> on 2012/03/20 10:55:40 UTC
[jira] [Created] (TRINIDAD-2245) ForEach tag throws
ArrayIndexOfBoundsException when the end attribute is same as the size of
the List
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
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
[jira] [Issue Comment Edited] (TRINIDAD-2245) ForEach tag throws
ArrayIndexOfBoundsException when the end attribute is same as the size of
the List
Posted by "Paresh Kumar Acharya (Issue Comment Edited) (JIRA)" <de...@myfaces.apache.org>.
[ 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
[jira] [Updated] (TRINIDAD-2245) ForEach tag throws
ArrayIndexOfBoundsException when the end attribute is same as the size of
the List
Posted by "Scott O'Bryan (Updated) (JIRA)" <de...@myfaces.apache.org>.
[ https://issues.apache.org/jira/browse/TRINIDAD-2245?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Scott O'Bryan updated TRINIDAD-2245:
------------------------------------
Resolution: Fixed
Fix Version/s: 2.0.2-core
Status: Resolved (was: Patch Available)
> 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
> Assignee: Scott O'Bryan
> Fix For: 2.0.2-core
>
> 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
[jira] [Updated] (TRINIDAD-2245) ForEach tag throws
ArrayIndexOfBoundsException when the end attribute is same as the size of
the List
Posted by "Paresh Kumar Acharya (Updated) (JIRA)" <de...@myfaces.apache.org>.
[ https://issues.apache.org/jira/browse/TRINIDAD-2245?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paresh Kumar Acharya updated TRINIDAD-2245:
-------------------------------------------
Status: Patch Available (was: Open)
> 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
>
> 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