js| Page | When displaying data as a list, pages need to be page-controlled and are used in almost every module of the project. In order to maximize the reuse and portability of paging, the flip logic is encapsulated in the form of components.
Analysis of the paging controller
Describe:
The paging controller is used to control the display of page paging and the various operations of paging. The paging content is displayed to the Web page through a JSP call. It supports a variety of ways and styles of display.
Design of page-turning controller
The following creates a Pageconfig class, a page class, and a PageView class for the paging controller respectively.
? Pageconfig.java
Class
Class Pageconfig
Declaring public class
Describes the values that this class uses to hold page properties, such as displaying several rows per page.
Super class
Perform
Attribute description
Attribute Property Description Definition
[Pageconfig]
|--page_size page size public static final int
|--page_size_small Small page size public static final int
|--page_size_normal normal page size public static final int
|--PAGE_SIZE_BIG large page size public static final int
|--page_size_bigger larger page size public static final int
|--page_size_biggest maximum page size public static final int
? Page.java
Class
Class Page
Declaring public class
Describes the values that this class uses to hold page properties, such as displaying several rows per page.
Super class
Execute java.lang.Serializable
Attribute description
Attribute Name attribute Description data type
|--empty_page a blank page describes a blank page, a page that contains no content. Page Object
|--objects result set list result set list java.util.List or Java.util.Vector
|--start start record number starting record number, starting with 0 positive integers and 0
|--end End record number ending record number positive integer and 0
|--viewstart display at page start record number displayed at page start record number, positive integer starting from 1
|--viewend display at page end record number displayed at page end record number positive integer
|--hasprevious whether there is a previous-page switch Boolean value for the previous page
|--previouspagenumber previous page page number positive integer and 0
|--hasnext whether there is a next-page switch Boolean value for the next page
|--nextpagenumber Next Page page number of the next page positive integer and 0
|--total total number of rows in which a positive integer and 0 are recorded
|--totalpage Total Pages A total number of pages
|--currentpagenumber The current page describes the current number of pages positive integers and 0
|--pagesize Page size Describes how many rows of positive integers and 0 per page
Construction device
Constructor Constructor Description parameter
[Page]
|--page (List l, int s, boolean hasnext) create page l result set S start record number, starting from 0 Hasnext whether there is a next page of the switch
|--page (List l, int s, boolean hasnext, int total) Create page l result set S start record number, starting from 0 Hasnext whether there is a total number of lines on the next page of the switch total
|--page (List l, int s, int size, Boolean hasnext, int total) Create page l result set S start record number, starting from 0 size how many rows per page Hasnext whether there is a switch to the next page total how many Line record
|--page (List l, int num, int size, int total) Create page l result set NUM is currently page size how many rows per page total there are records
|--page (List l) Create pages without paging L result set
Method
Method method describes the return value
[Page]
|--autocalculate () automatically calculates the value of other properties based on the current page, page size, total number of rows, private void
|--getlist () Get result set public List
|--getviewstart () Gets the start record number displayed on the page, starting with 1 public int
|--getviewend () Gets the end record number public int displayed on the page
|--hasnextpage () If there is a next page public boolean
|--haspreviouspage () If there is a previous page public boolean
|--getpreviouspagenumber () Gets the page number public int on the previous page
|--getnextpagenumber () Gets the page number public int for the next page
|--gettotal () Get the total number of rows in the result set public int
|--gettotalpage () get total pages public int
|--getcurrentpagenumber () Get current page number public int
|--getpagesize () Get the number of rows per page for public int
|--getstartofnextpage () Gets the record number of the next page that starts in the result set, starting at 0 public int
|--getstartofpreviouspage () Gets the record number from the previous page that started in the result set, starting at 0 public int
|--getsize () Gets the number of rows that are included in the current page public int
|--isempty () Determines whether the current page is a blank page, returns true if the current page is a blank page, otherwise returns false public Boolean
Pageview.java
Class
Class PageView
Declaring public class
Describes how paging content is displayed to a Web page through a JSP call. Pictures, buttons, etc. are not supported, only text is supported. Usage: The JSP page is defined as follows: <% pageview view = new PageView (request,out,page); %> Displays <% view.setvisible (true) in default form; %> display <% view.setvisible (true,0,1) in the specified form; %>
Super class
Perform
Attribute description
Attribute Name attribute Description data type
[PageView]
|--currenturl the URL of the current page for the current page URL string
|--style Style style string
|--usesquarebrackets whether the [] switch adds a "[" and "]" Boolean value on both sides of the "previous page"
|--page Web page Web Page object
Construction device
Constructor Constructor Description parameter
[PageView]
| |--PageView (httpservletrequest request,jspwriter out,page page) Create a page content request client requests out page Output Object page Web pages
Method
Method method describes the return value
[PageView]
|--setvisible (Boolean visible) displays the paging content by default, and if visible is true, the paging content is displayed, otherwise, the paging content is not displayed public void
|--setvisible (Boolean visible,int style,int order) Displays the paging content in the specified form and, if visible is true, displays the paging content, otherwise, does not display the paging content public void
|--setvisible (Boolean Visible,boolean usesquarebrackets,int style,int order) Displays the paging content in the specified form and, if visible is true, displays the paging content, otherwise Do not show paging content public void
|--viewpage (Boolean usesquarebrackets,int style,int order) Displays the paging content in the specified form, which is 0, representing the full form, as shown in the following sequence: Total: 18 page: 2 Current page: 1 per page: 10 First Prev Next last go to----order for 1, the concise form, as shown in the following order: the previous page after the last 1/2order 2, the full form 2, in the following order: Total: 18 per page: 10 go to----first page back next last 1/2 public voi D
The encoding of the paging controller
Just press the design of the page controller to encode it, there's no need to talk about it.
Source code for the paging controller component
A) Pageconfig.java
b) Page.java
c) Pageview.java
Source code: Download Now
Call to Page Controller
The paging controller call is too simple to invoke the method:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.