You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by simon <sk...@apache.org> on 2008/05/03 20:27:02 UTC

Re: Use of t:datascroller with t:datatable and preserveDataModel="true"

Todd,

When someone replies to an email in the "bottom posting" style, it makes
things really hard to read if you then reply in top-posting style. It
could also be considered rude. I'll use top-posting style in my reply
here to avoid making things worse.

It is not the responsibility of a dataTable to preserve list contents in
any way. And the t:dataScroller does not "limit indexes".

The standard UIData component has:
 * property "rows" which controls how many rows should be rendered
 * property "first" which controls what the first row to render is

A UIData does *not* serialize the DataModel instance it is using as the
source of the data it iterates over. The only thing it saves is state
for the nested *component* objects. And unless your table contains
editable components, or command components then they don't really have
any state worth saving anyway.

The datascroller is just a component that manipulates these values on an
associated UIData component. The existence of a datascroller on the same
page is extremely unlikely to affect the way a UIData serializes the
state of its child components.

The most likely answer to your original problem is that the datascroller
is querying the table's datamodel object to find how many rows it has,
and then finds that value is less than the table's "rows" property.
There is therefore no "paging" to be done; all available data fits on
one page. And you have set "renderFacetsIfSinglePage" to true, so the
datascroller does not render itself.

So you should check whether table.datamodel.rowCount is less than
table.rows when the problem occurs.

Or set renderFacetsIfSinglePage to true, as I originally suggested, and
see what happens.

Regards,
Simon

On Wed, 2008-04-30 at 08:19 +1200, Todd Nine wrote:
> I believe that the issue is that the dataScroller in conjunction with
> dataTable does not correctly preserve the list contents.  From my
> understanding, the dataScroller is a decorator that limits the indexes
> that are displayed in the dataTable.  When I step through the source,
> it appears that the dataTable is only serializing the indexes that are
> currently displayed, not all indexes in the bean.  This doesn't seem
> to be the correct behavior when a data scroller is present, since the
> collection contains items that are not currently displayed, and should
> be serialized.  Is this a bug?
> 
> On Tue, Apr 29, 2008 at 10:37 PM, simon.kitching@chello.at
> <si...@chello.at> wrote:
>         Todd Nine schrieb:
>         > Hi All,
>         >   I'm trying to use t:dataScroller and t:dataTable
>         together.  I have
>         > everything working when the attribute "preserveDataModel" is
>         left off
>         > of my data table.  However, when I add it and set it to
>         true, my
>         > dataScroller is no longer rendered when the view is
>         restored.  For
>         > instance, here is a scenario that causes the dataScroller to
>         not get
>         > rendered.
>         >
>         
>         >    1. Admin enters date range
>         >    2. DB is queried, and the data table is rendered with the
>         scroller.
>         >    3. Admin scrolls to page 2
>         >    4. Admin clicks on a row to view the specifics.  This
>         takes them to
>         >       another page
>         >    5. Admin clicks "back to search results" which simply
>         loads the
>         >       page from step 2 without submitting a date range
>         
>         >    6. The data table is correctly restored to page 2,
>         however my
>         >       scroller no longer appears.
>         >
>         > Is there an attribute I'm missing?  I can't seem to get this
>         to work,
>         > and its becoming very frustrating.  I'm using MyFaces 1.2.2
>         and
>         
>         > Tomahawk 1.1.6. <http://1.1.6.> Below is the code for my
>         table tag and
>         > scroller with the body omitted.  I have also tried embedding
>         the
>         > dataScroller in the footer facet of the dataTable, but this
>         doesn't
>         > seem to make any difference.
>         >
>         >
>         >
>         >     <t:dataTable value="#{reloadRequest.searchResults}"
>         var="currRequest"
>         >                 id="requests" rows="25"
>         rowClasses="oddrow,evenrow"
>         >                 styleClass="datatable"
>         preserveDataModel="true">
>         > .....
>         >     </t:dataTable>
>         >
>         >    <t:dataScroller id="pager" for="requests"
>         pageCountVar="pageCount"
>         >                 pageIndexVar="pageIndex"
>         rowsCountVar="rowsCount"
>         >                 firstRowIndexVar="firstRowIndex"
>         >                 displayedRowsCountVar="displayedRowsCount"
>         >                 paginator="true"
>         >
>         >                 paginatorMaxPages="9"
>         paginatorTableClass="paginator"
>         >
>         paginatorActiveColumnStyle="font-weight:bold;"
>         > immediate="true"
>         >                 renderFacetsIfSinglePage="false"
>         styleClass="navigation">
>         >
>         > ....
>         > </t:dataScroller>
>         
>         
>         What happens if "renderFacetsIfSinglePage" is set to true?
>         Perhaps for
>         some reason the datascroller thinks your data model fits on
>         one page?
>         
>         Regards,
>         Simon
>         
>