DataTable and db paging

UI Components for JSF
Post Reply
pieter.martin
Posts: 8
Joined: 15 May 2010, 16:36

02 Jun 2010, 15:33

Hi,

I am using jboss 5, seam 2.2.0 and primefaces 1.0.2.

I am trying to use the db paging functionality of the DataTable.

The table is coming up nicely but the previous and next links are disabled.

It always says "0 of 0"

My page is as follows

Code: Select all

<p:dataTable var="objectVar" value="#{crudLazyDataModel}" paginator="true" rows="3" dynamic="true" lazy="true"
		paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}">

		<p:column resizable="true">
			<f:facet name="header">
				<h:outputText value="Ahem" />
			</f:facet>
			<h:outputText value="#{objectVar.name}" />
		</p:column>
	</p:dataTable>
And the LazyModel is

Code: Select all

	@Override
	public List<AbstractEntityInterface> fetchLazyData(int first, int pageSize) {
		List resultList = new ArrayList(100000);
		resultList.addAll(entityManager.createQuery(constructHsql()).setFirstResult(first).setMaxResults(pageSize).getResultList());
		return resultList;
	}
Am I suppose to do something special with paginatorTemplate? put el expressions in there?

Thanks
Pieter

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

04 Jun 2010, 10:38

No you don't need to, do you provide a LazyDataModel to the datatable?

pieter.martin
Posts: 8
Joined: 15 May 2010, 16:36

04 Jun 2010, 21:30

Hi,

Got it to work. As seam instantiated the LazyDataModel, the totalNumRows was never set.

Perhaps to make things easier for seam users you can provide a setter for the totalNumRows on LazyDataModel as seam can not call constructors with parameters.

I had to create a class which extends LazyDataModel and reimplements the logic contained in it.

Thanks
Pieter

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

07 Jun 2010, 11:59

Thanks for the feedback Pieter, we'll improve this when working on lazy sorting/filtering.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 44 guests