Primefaces : lazy loaded datatable's paginator buttons not showing - pagination

i have previously used datatable pagination and it worked as a charm. This time i needed to use the lazy loaded pagination and its showing the first page and there are no paginator buttons. I have tried a lot of things but it just isnt showing the paginator buttons. if i change the number of rows, it works i.e the number of rows on tht page changed but the paginaotor buttons are not showing. if i inspect the datatable in chrome, it shows thr is a div for the paginator bottom
<div xmlns="http://www.w3.org/1999/xhtml" id="j_idt7:contentTable_paginatorbottom" class="ui-paginator ui-paginator-bottom ui-widget-header ui-corner-bl ui-corner-br"></div>
this is my datatable
<p:dataTable id="contentTable" value="#{chatroomBean.lazyLoadedChatroomBeans}"
var="chatroom" paginator="true" paginatorPosition="bottom" rows="10" lazy="true"
paginatorTemplate=" {PreviousPageLink} {CurrentPageReport} {NextPageLink} "
rendered="#{chatroomBean.chatroomSearchText!=null}">
i am using jsf2, primefaces 2.2.1 and apache tomcat 6.
any help idea will be much appreciated. thanks
regards
khizar

I think you've run into this bug.
From the linked-to forum discussion:
Here is a workaround. Copy the
following lines in your load-Methode,
to update the pagination:
RequestContext context =
RequestContext.getCurrentInstance();
if(context!=null)context.addCallbackParam("totalRecords",
i);
The Variable i stand for the result of
the projections query.

its late but i just saw this question n remembered tht i had solved the prob so i thot i shud leave an answer here just in case sum1 else runs into it. the problem was tht the theme i was using cudnt find the images for the buttons, due to sum reason i cant remember now, i was not using the jar for the theme, i just added the theme.css to my project and it started working ... only problem was the links to images in the theme.css were like
url("#{resource['primefaces-glass-x:images/default.png']}") 0 0
changed them to this
url(images/default.png) 0 0
n it works like a charm ...
another solution (n probably the better one) wud be to add the jar for the theme in classpath and add the theme to web.xml but everyone probably knows tht ... :)
Regards,
khizar

Related

Primefaces datatable and current page not working

I'm using Prime Faces 6.0.
I've a datatable with a LazyDataModel. The user can change the page with the built-in paginator.
When the user switch from the first page, to the second I need to know the currentPage, and I need it in the client part.
This is the code of the datatable
<p:dataTable
id="listingsTable"
value="#{listingsLazyDataModel}"
var="actualAd"
paginator="true"
rows="#{applicationScopedBean.advertisingsPaginationSize}"
lazy="true"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="10,20,30"
paginatorPosition="bottom"
widgetVar="listingsTableDesktop"
first="#{searchAdvertisingModel.currentPage*applicationScopedBean.advertisingsPaginationSize}">
...
...
<p:ajax event="page" listener="#{listingsController.pageChanged}" oncomplete="pageChangedOnDetails(PF('listingsTableDesktop'))" />
...
---
</p:dataTable>
and this is the js code
function pageChangedOnDetails(listingsTableDesktop){
console.log(listingsTableDesktop.paginator.getCurrentPage());
}
The problem is that the getCurrentPage() method returns the previous page. Not the actual one. Just for information, the page is base 0. So the first page is the page 0.
Example of the actual behaviour vs expected one
User land in the page and see the first page.
User switch to the second page. getCurrentPage -> 0 WRONG expected 1
User switch to the third page. getCurrectPage -> 1 WRONG expected 2
User switch to the first page. getCurrentPage -> 2 WRONG expected 0
In which way can I solve this?
Thank you
The base is 0 but your event function is running way to soon it seems.
Try running your function else where other then event="page".
I mean by this, when your page is a 1 (default) and you click for example on page 3, it outputs a 0 (0+1= page 1) and ONLY AFTER THAT it goes to page 3. If you click on page 6 now, it outputs a 2 (2+1= page 3) and ONLY AFTER that it goes to page 6.
This happen even with oncomplete instead of onclick. Hope it helped.
This problem was a bug found in PF 6.0 and 6.1, but with the current version (6.2) this problem is solved

bootsfaces b:commandButton in ui:repeat not updating h:graphicImage

I'm using the 0.7 version of bootsfaces to create a simple page, which has something like the following:
<h:form id="some_form">
<ui:repeat id="some_elements" var="property" value="#{someBean.properties}">
<b:commandButton value="ShowProp" ajax="true" actionListener="#{someBean.showProperty(property)}" update=":some_form:some_elements:graphic"/>
<!-- This property is true -->
<ui:fragment rendered="#{someOtherBean.showGraphic}">
<h:graphicImage url="gen_image?id=#{property.id}" id="graphic"/>
</ui:fragment>
</ui:repeat>
</h:form>
Now, the idea is that on clicking the button, a property is updated and the image should be re-generated (in this case a jfreechart graph - but this is besides the point.) I tested this with primefaces commandButton and it works fine (the graph is redrawn..) However with bootsfaces commandButton, nothing happens once the ajax call completes (I can see the call on the server side, but the graph is not reloaded.) I think it's down to how it must reference the image in the repeated block, but now sure what is wrong - has anyone come across this?
(NOTE: reason I don't want to use primefaces is that it does not integrate well with bootstrap)
I've opened a bug on the project's bugtracker (https://github.com/TheCoder4eu/BootsFaces-OSP/issues/135).
Actually, why did you expect the update=":some_form:some_elements:graphic" to work in the first place? This expression is an id that doesn't exist. The id is some_form:some_elements:0:graphic. In other words: it contains the row number. PrimeFaces (and Mojarra and MyFaces) recognizes that the command button is part of a UIRepeat group and guesses the correct row number. But that's just a guess. Obviously a reasonable guess, because most of the time you want to update something that's in the vicinity of the command button.
The next version of BootsFaces is going to guess the correct row number, too :).

JSF - How to reset the <ice:dataTable> value list

Couple of days ago I started JSF with Iceface. I have a dataTable and when I delete a row,
It deletes the particular list entry from the back-end. Also dataTable remove a row, but not the one I deleted.
(It is not about the complete row. Its only a column.)
I'm using a suggestion box for each row. Problem only happens with that suggestion box field. But without that suggestion box, it works fine.
I thought if I could refresh/sync again the dataTable with it's bean property, just before rendering it, might solve the problem.
(From back-end it maintains the exact data set that I want to populate in my dataTable.)
At the moment what I want to know is, how can we re-sync the dataTable with it's new value, before render the response.
If you have any other idea please share it with me.
Thanks!
I have done a mistake :(
I haven't add the value="#{o.itemId}" property.
This is my suggestion box.
Thanks!
<ice:selectInputText id="sugestBox" rows="10" width="290"
listVar="item"
valueChangeListener="#{o.itemAutoCompleteBean.updateList}"
actionListener="#{o.lst}"
listValue="#{o.itemAutoCompleteBean.matchesList}"
value="#{o.itemId}">
<f:facet name="selectInputText">
<ice:panelGrid columns="3" style="margin-bottom:20px; "
columnClasses="sgstItemDropCol,sgstItemDescCol,sgstItemCatCol" >
<ice:outputText value="#{item.itemId}"/>
<ice:outputText value="#{item.description}"/>
<ice:outputText value="#{item.category}"/>
</ice:panelGrid>
</f:facet>

PrimeFaces 3.2 DataTable "jump to page" paginator template?

According to the official PrimeFaces 3.2 documentation, the paginator template can be a combination of the following predefined paginator templates:
{FirstPageLink}
{LastPageLink}
{PreviousPageLink}
{NextPageLink}
{PageLinks}
{CurrentPageReport}
{RowsPerPageDropDown}
This is fine for small data sets, but it's extremely hard to navigate thru the pages if the data set is huge: imagine you have a few thousands (or even more) of pages, you're at the very first start, page No. 1, and you want to jump directly to page No. 813, and then -- to No. 499). So:
Is there a way to enhance the existing templates set for the paginator in PrimeFaces 3.2 DataTable, e.g. adding a custom template?
If not, ... is there a way (I assume it as a potential hack) affect the data table navigation like in the scenario I described above?
Your help would be really appreciated.
Thanks in advance.
There is a paginator option {JumpToPageDropdown} you can use to select the page from the dropdown. I don't think it is documented.

jsf primefaces - two p:dataTable pagination questions

I'm using a p:dataTable with pagination like so:
<p:dataTable var="user" value="#{userBean.users}"
paginator="true" rows="20"
paginatorTemplate="{PageLinks}" >
Two questions:
1) Is there a way to tell it to not show the page numbers when there's only one page?
2) When I click from page 1 to page 2, the whole web page refreshes. On the PrimeFaces demo the pagination flips pages with an AJAX-style update. What have I done wrong that the web page is refreshing?
Any help is greatly appreciated, thanks!
rob
Try the following for question 1:
paginatorAlwaysVisible="false"
From the primefaces javadoc:
paginatorAlwaysVisible: Defines if paginator should be hidden when number of rows displayed is less than paginator rowsPerPage option.

Resources