Jump-to-page drop down list on datatable

UI Components for JSF
Post Reply
anniehavile
Posts: 5
Joined: 24 Nov 2011, 18:52

24 Nov 2011, 19:25

Hi all,

I'm using datatable with paginator. Pagination template has many options. Does it have {JumpToPageDropDown} as in YUI library ? If not, how can I get / implement it ? Currently, I need a page drop-down list to navigate to the remain pages (instead of page link buttons).
Please give me some advice on this issue. My current version of Primefaces is 2.2.1.

Thanks all !

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

24 Nov 2011, 20:07

It's not available in 3.x, you can create a feature request. It may be looked in 3.FUTURE if it get user votes.

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

25 Nov 2011, 05:38

Agreed. This would be a nice feature to have, especially after I realized how many pages of data that can be browsed via lazy dataTable in my JSF/PrimeFaces web app. When I see that 181 pages for browsing list of Customers, my first thought was an A .. Z navigation set of buttons. I have yet to implement that, but I surely don't mind implementing that myself, since I already have custom FilterBy and Sort buttons/fields that query the database accordingly. writing this response just reminded me that I'd like to do that. So, thanks! :)
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

BalusC
Posts: 36
Joined: 23 Jul 2010, 20:21

12 Dec 2011, 20:20

While looking for how to customize/finetune the generated UI of the paginator element in PF 3.0 M4, I found a JumpToPageDropdownRenderer. This can be activated by a {JumpToPageDropdown} in paginatorTemplate attribute. It is however undocumented in 3.0 M4 User Guide, can we assume that this new feature is permanent?

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

12 Dec 2011, 21:21

BalusC wrote:While looking for how to customize/finetune the generated UI of the paginator element in PF 3.0 M4, I found a JumpToPageDropdownRenderer. This can be activated by a {JumpToPageDropdown} in paginatorTemplate attribute. It is however undocumented in 3.0 M4 User Guide, can we assume that this new feature is permanent?
Thank you BalusC! I just added this to all my p:dataTable pages that reference lazyDataModel, and it works great. I wonder if it is using "page" AJAX event as well. If so, I need to add p:ajax event="page" listener="bean.method" to these same pages to update p:ajaxStatus on my page, because my ajaxStatus is not updated at all when I use the paginator buttons. :(

Depending on Optimus.Prime's response to this post/finding, I think we need to create a New Issue on Issue Tracker, and pose your/BalusC's question there to get a sure response from Optimus.Prime just in case he does not see this conversation. :)
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

12 Dec 2011, 21:42

Issue # 3033 (please click URL and star this issue to be fixed)
http://code.google.com/p/primefaces/iss ... il?id=3033

After posting my previous response, I've been testing BalusC's find/discovery, and the following error is the result:

Code: Select all

INFO: START PHASE RESTORE_VIEW 1
INFO: END PHASE RESTORE_VIEW 1
SEVERE: java.lang.IndexOutOfBoundsException: toIndex = 1126
Screen capture 1 of 2: jumped to page # 113
Image

Screen capture 2 of 2: clicked 'A' button that shows all customers that begin with 'A', and the SEVERE error (above) was the result.
Image

bean getter/setter (filter buttons on the page results in filtering the result set via SQL SELECT in DAO or entity Facade object)

Code: Select all

    public LazyDataModel<Customer> getLazyModel() {

        try {
            /* *** MAY NEED TO REMOVE if (lazyModel == null) *** */
            if (lazyModel == null) {

                // filter by
                if ((filterCustomerId != 0) || filterCustomerName.length() > 0 || filterCustomerNameBeginWith.length() > 0) {

                    lazyModel = new LazyCustomerDataModel(getFacade().filterBy(filterCustomerId, filterCustomerName,
                                                                               filterCustomerNameBeginWith, sortBy));
                }
                // first approach for lazy datatable; filterBy and sortBy columns don't work
                else {
                    lazyModel = new LazyCustomerDataModel(getFacade().findAllSortBy(sortBy));
                }

            } // lazyModel == null
        } catch (Exception e) {
            e.printStackTrace();
            messages.addFormErrorMsg("Error retrieving list of Customers", (e.getMessage() != null) ? e.getMessage() : "");
        }
        return lazyModel;
    }

    public void setLazyModel(LazyDataModel<Customer> lazyModel) {
        this.lazyModel = lazyModel;
    }

xhtml/jsf

Code: Select all

<p:dataTable id="dt_selectCustomerForOrder" var="customer" value="#{pf_customerController.lazyModel}" 
	paginator="true" paginatorAlwaysVisible="false" rows="10" rowsPerPageTemplate="10,25,50,100,500,1000"
	paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}  {JumpToPageDropdown}"
	selection="#{pf_customerController.selectedRow}" selectionMode="single">

        <p:ajax event="page" update=":@this :@form:_ajax_status"/>
What is the best way to get around this SEVERE error? I wonder if I can update (or "reset") the sublist or pageIndex in lazyDataModel on server side when I use/click other filter or page Navigation options on p:dataTable. Hmmm....
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

20 Dec 2011, 22:06

Solution (for later reference or for anyone interested), see forum post below:

LazyDataModel java.lang.IndexOutOfBoundsException: toIndex =
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

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

21 Dec 2011, 00:14

My bad, we had implemented jumptopagedropdown in M4, RC1 and RC2. PF has too much stuff I can't remember all it seems.

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

21 Dec 2011, 00:34

optimus.prime wrote:My bad, we had implemented jumptopagedropdown in M4, RC1 and RC2. PF has too much stuff I can't remember all it seems.
Cagatay, I completely understand!!! I can NEVER remember code that I've developed in the past; i always have to globally search code unless i'm in that code (too) often. Thanks for the response.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 37 guests