JSF Datatable current Page Primefaces - jsf

I would like to display the current page of a datatable outside of the table (I actually need it for paging a the items on a google maps component). How can I get the current page of the datatable?
Thanks,
D

In tomahawk you can use dataScroller pageIndexVar (only inside datascroller component)
<t:dataScroller for="data_table" pageIndexVar="current_page">
<h:outputText value="#{current_page}" />
</t:dataScroller>
http://myfaces.apache.org/tomahawk-project/tomahawk/tagdoc/t_dataScroller.html

Related

Primefaces remoteCommand refreshing datatable automatically, setting to first page of DataTable

When Im on other than frist page of DatTable and im using button from rowExpansion or even commandLink used in row, page is beeing set to first automatically
<p:remoteCommand name="xyz" action="#{xBean.refreshXList()}" process="#this"/>
when this code is deleted DataTable page is not changing to first, ingoreAutoUpdate="true" not helping with it.

How to show row number information on rich datatable?

I'm trying to show the following text on the footer of my table:
Showing 11 to 20 of 51 entries
But I can't find a way to do it. I didn't find any vars in the footer that give me those variables easily.
I also tried to create a class that inherits from ExtendedDataModel and kept the values there.
I got the number of the row from the sequenceRange in the walk method. But, apparently, the footer of the table is rendered before the walk method being called, which resulted that the info on the bottom of my page was outdated by one request.
Any suggestions on how to do this?
By the way, I'm using JSF 2.1 and RichFaces 4.3.0 Final.
You can use the built in datascroller feature of rich faces:
Update 1
The scroller has a default layout which you might not want. But you can customize it. see Scroller Facets Usage tab in this link. Copying here:
<f:facet name="pages">
<h:panelGroup>
<h:outputText value="Page "/>
<h:selectOneMenu value="#{dataScrollerBean.scrollerPage}"
onchange="#{rich:component('ds')}.switchToPage(this.value)">
<f:selectItems value="#{dataScrollerBean.pagesToScroll}" />
</h:selectOneMenu>
<h:outputText value=" of #{pages}" />
</h:panelGroup>
</f:facet>
Refer this link:
Datascroller
This example shows the number of rows in a datatable in datascroller based on size mentioned in rows attribute of dataTable.

How get row index of <ace:dataTable> in every row?

In searching I found that we can do something with rowStateVar or rowIndex attributes of <ace:datatable>, but how?
I tried using <h:outputText value="#{myDataTableVar.rowIndex}"> but it shows an error message that myDataTableVar has no property rowIndex.
For a component library independent way, just use UIData#getRowIndex() as every component library specific datatable extends from this base component.
In the below example, x: can be anything: standard JSF h:, ICEfaces ice: or ace:, PrimeFaces p:, RichFaces rich:, etc.
<x:dataTable binding="#{table}" ...>
<x:column>#{table.rowIndex}</x:column>
</x:dataTable>
Note: the binding="#{table}" is as-is! You don't need to bind it to some managed bean property.
I found the solution <ace:datatable id='tbl' rowIndexVar="row"> and then just print like that <h:outputtext value="#{row}">Very simple
First, set varStatus:
<ice:dataTable varStatus="status">
An then, inside that dataTable, use:
#{status.index}

When pagination is activate in p:dataTable?

I am using primefaces 3.2
How can I know when the user is pushing one of the pagination button in p:dataTable ?
Thanks
If you need an ajax behaviour when user changes the page, you can use the following code:
<p:dataTable value="#{bean.collection}" var="obj" >
<p:ajax event="page" update="componentsToUpdateOnPage" listener="#{bean.pageListener}" />
<p:column>
.. etc..
</p:dataTable>
If you are using a lazy loading data table, you have to override the load() method of LazyDataModel. that method is executed on page load, when page changes and also when you sort or filter the datatable.

Layout and (nested?) DataTables in PrimeFaces

I am trying to dispose a p:dataTable beside a p:button. They need to lay in a p:tab that is contained in a p:tabView. The tabView is contained in the central p:layoutUnit of a p:layout.
I also need to put the dataTable inside a form for producing an ajax update of another component.
Before trying to add the button on the left of table, everything was fine:
<p:layout ...
<p:layoutUnit ....
<p:tabView ....
<p:tab ....
<h:form ....
<p:dataTable .....
But when adding an outer h:dataTable just out of the h:form, the tabView appears empty. If I try to use an outer p:dataTable, only one table is displayed without items.
Are there any limitations in putting a dataTable into another dataTable? If yes, are there other ways to reach this goal?
UPDATE
I have found that the right way is to use nested Layouts, a feature available since Primefaces 3.0 which is not yet fully documented.
Here is the link to the feature request and links to the showcase-lab.

Resources