On Sun, 2006-01-01 at 11:21 +0700, Pichai Ongvasith wrote:
> Hello,
>
> I tried to use a ResultSetDataModel as the data model for <t:dataTable>,
> with myfaces1.1.1. It turns out that the result never shows up in the table.
> My guess is that this might be related to Jira issue MYFACES-278.
>
> Looking into the source code, I guess
> HtmlTableRendererBase.encodeInnerHtml is doing the job to render the
> result set.
> this is the excerpt of relevant code.
> int first = uiData.getFirst();
> int rows = uiData.getRows();
> int rowCount = uiData.getRowCount();
> if (rows <= 0)
> {
> rows = rowCount - first;
> }
> int last = first + rows;
> if (last > rowCount)
> last = rowCount;
>
> for (int i = first; i < last; i++)
> {
> // render
> }
>
> If that's true, the method might be mishandling the uiData.getRowCount.
> The implementation of ResultSetDataModel.getRowCount in myfaces1.1.1
> always return -1, which is valid when the row count is unknown at the
> time. So before the rendering loop, last is always -1, and nothing would
> be rendered.
>
> Or am I missing something here?
It sure looks to me like the ResultSet support is broken. As you say,
ResultSetDataModel.getRowCount always returns -1, so I can't see how
this code would ever work.
Perhaps the HtmlTableRendererBase.encodeInnerHtml method should look
more like this:
uiData.setRowIndex(first);
int offset = first;
while (uiData.isRowValid()) {
// render
if (offset > last)
break;
++offset;
uiData.setRowIndex(offset);
}
Regards,
Simon