سؤال

I have tried the solutions provided in rich:dataTable paging - marking visited pages of rich:datascroller but it didn't work with rich faces 4.3.4.

I have also tried page attribute of data scroller. Here's my code implementing page attribute of datascroller.

 <h:form id="mainForm">
     <rich:dataScroller for="itemDataTable" maxPages="30" execute="itemDataTable" page="#{itemsController.pageIndex}"/>                                 
     <rich:dataTable rowKeyVar="rkVar" rows="15" id="itemDataTable" value="#{itemsController.itemDM}" var="r">
     <f:facet name="footer">
        <h:outputText id="pageNumberOutPutText" value="#{itemsController.pageIndex}"/>
     </f:facet>
        <h:column id="setValue">
            <h:inputText id="finalItem" valueChangeListener="#{itemsController.recalculate()}" value="#{r.items.prices}"/>
        </h:column>
        ...
        ...
    <!-- other columns --> 
    </rich:dataTable>
    <rich:dataScroller for="itemDataTable" maxPages="30" execute="itemDataTable" page="#{itemsController.pageIndex}"/>                                      
</h:form>

I have respective getters and setters in my itemsController class and with following scope:

@ManagedBean
@ViewScoped

with pageIndex intially set to 1.

private int pageIndex = 1;

And I tried to alert the current page number using:

alert('You are in page : ' + $('#mainForm\\:itemDataTable\\:pageNumberOutPutText').val());

But it alerts only 1. Also the outputText in the datatable footer shows only 1 even if I click next page or click other pages.

Above all, all I wanted to do is alert the current page number using JQuery. I also dont want to use getters and setters for this, if possible. I really wanted to know how to get the current page number using Jquery.

هل كانت مفيدة؟

المحلول

Specify region to re-render with ajax request to update appropriate parts of the view. E.g.:

<rich:dataScroller render="pageNumberOutPutText"/>

نصائح أخرى

The current page number is in the JS object that backs the datascroller. You can get it with:

#{rich:component('scrollerId')}.currentPage
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top