Uploaded image for project: 'MyFaces Trinidad'
  1. MyFaces Trinidad
  2. TRINIDAD-2245

ForEach tag throws ArrayIndexOfBoundsException when the end attribute is same as the size of the List

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.1-core
    • 2.0.2-core
    • Components
    • None

    Description

      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>

      Attachments

        1. ForEachTag_trunk.patch
          0.8 kB
          Paresh Kumar Acharya

        Activity

          People

            darkarena Scott O'Bryan
            pareshacharya Paresh Kumar Acharya
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: