You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Gillmer J. Derge (JIRA)" <de...@myfaces.apache.org> on 2006/03/26 17:48:47 UTC

[jira] Commented: (MYFACES-278) UIData does not processColumnChildren() if rowCount() returns -1 (for ResultSetDataModel)

    [ http://issues.apache.org/jira/browse/MYFACES-278?page=comments#action_12371897 ] 

Gillmer J. Derge commented on MYFACES-278:
------------------------------------------

This isn't really fixed.  As the report indicates, any code that uses getRowCount is suspect.  One particular place where I've noticed a problem is in HtmlTableRendererBase.encodeInnerHtml, near line 130.

        if (last > rowCount)
            last = rowCount;

should be guarded in case rowCount is -1.  Something like:

        if ((rowCount >= 0) && (last > rowCount))
            last = rowCount;

Also, just below that an error is logged if a row is not available.  If rowCount is -1, it's not an error for a row to be unavailable.

> UIData does not processColumnChildren() if rowCount() returns -1 (for ResultSetDataModel)
> -----------------------------------------------------------------------------------------
>
>          Key: MYFACES-278
>          URL: http://issues.apache.org/jira/browse/MYFACES-278
>      Project: MyFaces Core
>         Type: Bug
>     Versions: 1.1.0
>     Reporter: Ahmed Ashour
>     Assignee: Martin Marinschek
>     Priority: Minor
>      Fix For: 1.1.0

>
> Any code that iterates the rows using getRowCount() would fail, because it might be -1 (for ResultSetDataModel).
> Instead, isRowAvailable() should be used to iterator over the rows, and "break" otherwise.
> E.g. in javax.faces.component.UIData
> private void processColumnChildren(FacesContext context, int processAction) {
> 		int first = getFirst();
> 		int rows = getRows();
> 		int last;
> 		if (rows == 0) {
> 			last = getRowCount();
> 		} else {
> 			last = first + rows;
> 		}
> 		for (int rowIndex = first; rowIndex < last; rowIndex++) {
> 			setRowIndex(rowIndex);
> 			if (isRowAvailable()) {
> Should be replaced with 
> private void processColumnChildren(FacesContext context, int processAction) {
> 		int first = getFirst();
> 		int rows = getRows();
> 		int last;
> 		if (rows == 0) {
> 			last = getRowCount();
> 		} else {
> 			last = first + rows;
> 		}
> 		for (int rowIndex = first; last==-1 || rowIndex < last; rowIndex++) {
> 			setRowIndex(rowIndex);
> 			if (isRowAvailable()) {
> 			} else
> 			        break

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