- Pagination utility class provided in the NetBeans integrated
development environment (IDE)
This tutorial covers the steps needed to implement the
pagination feature in a table of a JavaServer Faces (JSF) page.
Time to Complete
Approximately 45 minutes
JSF technology is a user interface (UI) framework for developing Java web applications. It is based on components, events, and Model-View-Controller (MVC) architecture. When building web applications in JSF, you first create a page structure by arranging JSF components in a tree.
DataTable component displays the data as an
HTML table through the <
UIColumn component represents a column of
data in the table. You can add several features to the
component, such as pagination,
sorting, filtering, in-cell editing, and scrolling.
The following figure shows a sample
component with pagination in a
In this tutorial, you look at part of a DVD library application
from the course entitled Java EE 6: Develop Web Applications
with JSF. You view the list of DVDs and their details in a
tabular format. Next, you add a pagination feature to the table
by applying the following techniques:
Hardware and Software Requirements
The following is a list of hardware and software requirements:
- Java Platform, Standard Edition 7 (Java SE 7; Java SE 7u11
- NetBeans 7.x IDE Java Platform, Enterprise Edition (Java EE
version; NetBeans 7.2 recommended)
- GlassFish 3.1.2 or Oracle WebLogic Server 12c
Before starting this tutorial, you should:
- Have some experience writing and deploying JSF web applications.
- Have installed and started NetBeans 7.2 Java EE.
- Have unzipped the DVDLibraryApp.zip file.
- Have opened the
DVDLibraryAppproject in NetBeans.
- Have created the
dvdlibarydatabase and the
Itemtable and added data to the
Itemtable according to the instructions in the
READMEfile and data in the dvdlibrary.sql file.
- (Optional) Have installed WebLogic Server 12c. See the resources section for more information about installing WebLogic Server and adding it to NetBeans.
Running and Examining the
Before starting, be sure to complete all points mentioned in the Prerequisites section.
You use the
PaginationHelper class and
class to implement pagination in your JSF page. Complete the
steps in the two subtopics.
Class in the
Note: Add the required import statements to the
Modifying the JSF Page to Use
Fields of the
Verifying the Pagination Feature in the JSF Page
Using the PrimeFaces
In this topic, you use PrimeFaces, a third-party library, to
provide the pagination feature for the
DataTable Component in the
Note: You modify the numbers displayed in the combo
box by modifying the value of the
attribute of the
In this tutorial, you learned how to:
- Use the
<h:dataTable>element in a JSF page
- Use the
javax.faces.model.DataModelclass to implement pagination
- Apply pagination in the
<h:dataTable>element in a JSF page
- Use the PrimeFaces
<p:dataTable>component and apply its pagination attributes in a JSF page
The application in this tutorial uses JSF Facelets, CDI beans, and Java Persistence API (JPA). To learn more about these technologies, see the following resources:
- Installing, Configuring, and Testing WebLogic Server 12c Developer Zip Distribution in NetBeans: This OBE covers how to install the Oracle WebLogic Server 12c (12.1.1) developer instance on Windows and configure it as a Java EE application server in NetBeans.
- Developing Applications with Java EE 6 on WebLogic Server 12c: This course covers the breadth of Java EE technologies that are part of the Java 6 Web Profile.
- Developing Web Applications using JSF Technologies: This course covers JavaServer Faces, the server-side component framework designed to simplify the development of user interfaces for Java EE applications.
- Building Database Driven Applications with JPA: This course covers JPA, the standard Java object-relational-mapping technology.
- The Java EE 6 Tutorial: The tutorial is an excellent source of information about the technologies included in Java EE 6, including CDI.
- To learn more about Java EE, visit other OBE tutorials in
Oracle Learning Library
- Lead Curriculum Developer: Paromita Dutta
- Reviewer: Tom McGinn
- Editor: Susan Moxley
- QA: Anjulaponni Azhagulekshmi
To help navigate this Oracle by Example, note the following:
- Hiding Header Buttons:
- Click the Title to hide the buttons in the header. To show the buttons again, simply click the Title again.
- Topic List Button:
- A list of all the topics. Click one of the topics to navigate to that section.
- Expand/Collapse All Topics:
- To show/hide all the detail for all the sections. By default, all topics are collapsed
- Show/Hide All Images:
- To show/hide all the screenshots. By default, all images are displayed.
- To print the content. The content currently displayed or hidden will be printed.
To navigate to a particular section in this tutorial, select the topic from the list.