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

    Resolution: Cannot Reproduce

problem can not be reproduced with the current nightly.

> PreserveDataModel not working (java.lang.IllegalArgumentException: row is 
> unavailable)
> --------------------------------------------------------------------------------------
>
>          Key: MYFACES-522
>          URL: http://issues.apache.org/jira/browse/MYFACES-522
>      Project: MyFaces
>         Type: Bug
>   Components: Tomahawk
>     Versions: Nightly Build
>  Environment: N/A
>     Reporter: Enrique Medina Montenegro
>  Attachments: _SerializableDataModel_Patch.txt
>
> When setting the preserveDataModel attribute in a dataTable, a new 
> _SerializableDataModel is internally build by MyFaces.
> However, if the number of rows to display is less than the total number of 
> possible rows, an IllegalArgumentException is thrown. This problem is caused 
> by the following bunch of lines in the _SerializableDataModel constructor 
> (public _SerializableDataModel(int first, int rows, DataModel dataModel)):
>     
>         _list = new ArrayList(rows);
>         for (int i = 0; i < _rows; i++)
>         {
>             dataModel.setRowIndex(_first + i);
>             if (!dataModel.isRowAvailable()) break;
>             _list.add(dataModel.getRowData());
>         }
>         _rowIndex = -1;
> As can be clearly seen, first the dataModel.setRowIndex is set, independently 
> of whether the row is really available or not, as it is checked after.
> The solution would be as simple as swapping the order:
>         _list = new ArrayList(rows);
>         for (int i = 0; i < _rows; i++)
>         {
>             if (!dataModel.isRowAvailable()) break;
>             dataModel.setRowIndex(_first + i);
>             _list.add(dataModel.getRowData());
>         }
>         _rowIndex = -1;

-- 
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