[ http://issues.apache.org/jira/browse/MYFACES-412?page=all ]
     
Mathias Broekelmann closed MYFACES-412:
---------------------------------------

    Fix Version: Nightly Build
     Resolution: Fixed
      Assign To: Mathias Broekelmann

fixed
Thanks to Mark Schechter for reporting and supplying a patch.

> _SerializableArrayDataModel throws ArrayIndexOutOfBoundsException when 
> x:DataScroller advanced to second page on x:dataTable backed by array
> --------------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: MYFACES-412
>          URL: http://issues.apache.org/jira/browse/MYFACES-412
>      Project: MyFaces
>         Type: Bug
>   Components: Tomahawk
>     Versions: Nightly Build
>  Environment: Windows 2000, Tomcat 5.5.
>     Reporter: Mark Schechter
>     Assignee: Mathias Broekelmann
>      Fix For: Nightly Build

>
> When the bound property in the backing bean for an x:dataTable ('value' 
> element) is an array, and the x:dataScroller is used, 
> _SerializableArrayDataModel throws an ArrayIndexOutOfBounds exception when 
> trying to advance to the second page.  Debugging through this code:
> 1    public _SerializableArrayDataModel(int first, int rows, Object[] array)
> 2   {
> 3        _first = first;
> 4        _rows = rows;
> 5        _rowCount = array.length;
> 6        if (_rows <= 0)
> 7        {
> 8            _rows = _rowCount - first;
> 9        }
> 10        _list = new ArrayList(_rows);
> 11       for (int i = 0; i < _rowCount; i++)
> 12        {
> 13            _list.add(array[_first + i]);
> 14        }
> 15    }
> the exception occurs on line 13 above, because on any page other than the 
> first page,  _first will be non-zero (say 20 on the second page if displaying 
> 20 rows at a time), and adding this to i which goes up to _rowCount will 
> exceed the length of the array.  The problem appears to be on line 11, i < 
> _rowCount; I presume it should be _rows instead, or better, some "size", as 
> calculated for example by similar code in class _SerializableListDataModel.  
> When I switch the bound property in the backing bean to be a List instead of 
> an array, it works fine (I presume because _SerializableListDataModel is 
> being used instead).
> Here is the dump from Tomcat 5.5:
> java.lang.ArrayIndexOutOfBoundsException: 164
>       at 
> org.apache.myfaces.component.html.ext._SerializableArrayDataModel.<init>(_SerializableArrayDataModel.java:42)
>       at 
> org.apache.myfaces.component.html.ext.HtmlDataTable.createSerializableDataModel(HtmlDataTable.java:493)
>       at 
> org.apache.myfaces.component.html.ext.HtmlDataTable.getSerializableDataModel(HtmlDataTable.java:470)
>       at 
> org.apache.myfaces.component.html.ext.HtmlDataTable.saveState(HtmlDataTable.java:369)
>       at 
> javax.faces.component.UIComponentBase.processSaveState(UIComponentBase.java:456)
>       at 
> javax.faces.component.UIComponentBase.processSaveState(UIComponentBase.java:452)
>       at 
> javax.faces.component.UIComponentBase.processSaveState(UIComponentBase.java:452)
>       at 
> javax.faces.component.UIComponentBase.processSaveState(UIComponentBase.java:440)
>       at 
> javax.faces.component.UIComponentBase.processSaveState(UIComponentBase.java:452)
>       at 
> org.apache.myfaces.application.jsp.JspStateManagerImpl.getComponentStateToSave(JspStateManagerImpl.java:70)
>       at 
> org.apache.myfaces.application.jsp.JspStateManagerImpl.saveSerializedView(JspStateManagerImpl.java:213)
>       at org.apache.myfaces.taglib.core.ViewTag.doEndTag(ViewTag.java:122)
>       at 
> org.apache.jsp.listTaggedItems_jsp._jspx_meth_f_view_0(org.apache.jsp.listTaggedItems_jsp:191)
>            ETC.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to