JSP General query processing and paging display __jsp

Source: Internet
Author: User

JSP universal query processing and paging display

Tieshu

Tieshu

Sunday, April 2, 2006

(Note: The source code involved can be obtained by email:rngguliu@163.com)

1 Basic Ideas

In view of JSP development many times use the function of query and paging display, so the query processing and pagination display of the unified design and function encapsulation, to a certain extent, speed up the development process, improve the coding efficiency, reduce duplication of labor, improve the degree of code reuse.

The process is as follows.

As can be seen from the above process, the entire query and pagination display retrieves only one database at a time, that is, only one database connection is established. When the page is displayed, no more queries are made. To a certain extent, reduce the burden of the system, while the speed of the page is also improved.

The note of this design is, for the session of the variable name processing, do not repeat, to avoid confusion, agreed to adopt "table name" and the corresponding operation of the combination, see the sample program. 22 Important Classes

These two classes of call interface and easy to master, simply call several methods, you can achieve the perfect paging display.

These two classes are relatively independent and practical and can be invoked separately in other programs. If you combine the two, you can achieve a perfect paging display of any set of objects. 2.1 page Pagination processing class

To simplify the processing of paging functionality, the paging-related processing is encapsulated in this class. The input parameter is a dataset (or collection of objects), the number of records displayed per page, and the number of pages to display, returning the recordset to display.

Overview of constructors

Page (java.util.List data, int itemsperpage) constructor 1,list dataset sets the DataSet and how many records each page displays and calculates the total number of pages and total records, 1 for the current page number

Page (java.lang.Object data, int itemsperpage) constructor 3,object dataset sets the DataSet and how many records each page displays and calculates the total number of pages and total records, 1 for the current page number

Page (java.util.Vector data, int itemsperpage) constructor 2,vector dataset sets the DataSet and how many records each page displays and calculates the total number of pages and total records, 1 for the current page number

Overview of methods

String

Getallfoot (string URL, string Pagepara)
Get footer information for pagination 2, showing invalid links

String

Getallfoot (string URL, String Pagepara, String Otherpara)//Get footer information for pagination 3, show invalid links, and handle associated child tables

Int

Getcurrentrecord ()//Get current record number

String

Getvalidfoot (string URL, string Pagepara)
Get footer information for pagination 1, automatically hide invalid links

String

Getvalidfoot (string URL, String Pagepara, String Otherpara)
Get footer information for pagination 1, automatically hide invalid links

Java.util.List

ShowPage (String pagenum)//To find the dataset to display based on the page number

Constructor details

Page

Public Page (java.util.List data, int itemsperpage)

The constructor 1,list dataset sets the DataSet and how many records each page displays and calculates the total number of pages and total records, setting the current page number to 1

Parameters:

Data-the dataset to display

ItemsPerPage-How many records are displayed per page

Page

Public Page (java.util.Vector data, int itemsperpage)

The constructor 2,vector dataset sets the DataSet and how many records each page displays and calculates the total number of pages and total records, setting the current page number to 1

Parameters:

Data-the dataset to display

ItemsPerPage-How many records are displayed per page

Page

Public Page (java.lang.Object data, int itemsperpage)

The constructor 3,object dataset sets the DataSet and how many records each page displays and calculates the total number of pages and total records, setting the current page number to 1

Parameters:

Data-the dataset to display

ItemsPerPage-How many records are displayed per page

Method details

Getcurrentrecord

public int Getcurrentrecord ()

Return value: The current record number.

ShowPage

Public java.util.List showpage (String pagenum)

Find the dataset to display based on the page number

Parameters:

Pagenum-The specified page number

Return value: The DataSet to display

Getvalidfoot

public string getvalidfoot (string url, string Pagepara)

Get footer information for pagination 1, automatically hide invalid links

Return value: Footer information for pagination

Getvalidfoot

public string getvalidfoot (string url, String Pagepara, String Otherpara)

Get footer information for pagination 1, automatically hide invalid links

Return value: Footer information for pagination

Getallfoot

public string getallfoot (string url, string Pagepara)

Get footer information for pagination 2, showing invalid links

Return value: Footer information for pagination

Getallfoot

public string getallfoot (string url, String Pagepara, String Otherpara)

Get footer information for pagination 3, show invalid links, and handle associated child tables

Return value: Pagination footer information 2.2 Face interface Display class

This class is packaged for the sake of uniformity and flexibility and simplicity of the interface. The calling interface is simple and practical.

Overview of Constructors

Face ()

Overview of methods

void

SetStyle (int styleindex)//Set display style, several color schemes are built (thanks to ezpj2005@yahoo.com.cn friends); 1 is the default style, you can set the color scheme yourself

String

Table ()//table header

String

Table (String width)//with parameter headers

String

Tablee ()//Footer

String

TD ()//table column display style//Show space

String

TD (int colspan, String label)//table column display style

String

TD (int colspan, string label, string align)//table column display style

String

TD (String label)//table column display style

String

TD (string width, int colspan, string label)

String

TD (string width, string label)

String

TDD (string value, String label)//Pop-up dialog box, link column (for example: delete)

String

TDD (string value, string label, String msg)

Pop-up dialog box, link column (for example: delete)

String

TDI (string width, int colspan, string value, String label)

String

TDI (string value, String label)//Link column

String

TDI (string value, String label, string method)//Link column

String

TH ()//table header display style//Show space

String

TH (int colspan, String label)//table header display style

String

TH (String label)//table header display style

String

TH (string width, int colspan, string label)

String

TH (string width, string label)

String

THI (string width, int colspan, string value, String label)

String

THI (string value, String label)//Link column

String

TR ()//Normal line display style (for example, call when adding, modifying, querying the interface, or part of the table header, footer note, etc.)

String

TRB ()//browse row display style (call when browsing and query results are displayed)

String

TRE ()//end of line flag

Constructor Details

Face

Public Face ()

Method Details

SetStyle

public void SetStyle(int styleindex)

Sets the display style, built-in several color schemes (thanks to ezpj2005@yahoo.com.cn friends), 1 is the default style, you can set the color scheme yourself

Parameters: Styleindex-

Table

Public String table () header

Table

public string table (string width) with parameter headers

Parameters:

Width-//table widths

Tablee

Public String Tablee() footer

Tr

Public String TR()

Normal line display style (for example, call when adding, modifying, querying the interface, or part of the table header, footer note, etc.)

TRB

Public String TRB() Browse row display style (called when browsing, query results are displayed)

TRE

Public String TRE()//end of line flag

TH

Public String TH() table header display style//Show space

TH

Public String TH(String label) table header display style

Parameters:

Label-//What to display

TH

Public String TH(int colspan, String label) table header display style

Parameters:

Label-//What to display

colspan-//cross-column display

TH

public string TH(string width, string label)

Parameters:

Width-//column widths

Label-//What to display

TH

public string TH(string width, int colspan, string label)

Parameters:

Width-//column widths

colspan-//cross-column display

Label-//What to display

THI

public string THI(string value,

String label)

Link columns

Parameters:

Label-//display content

Value-//content to be linked

THI

public string THI(string width, int colspan, string value, String label)

Parameters:

Width-//column widths

colspan-//cross-column display

Value-//content to be linked

Label-//What to display

Td

Public String TD() table column display style//show spaces

Td

public string TD(String label) table column display style

Parameters:

Label-//What to display

Td

public string TD(int colspan, String label) table column display style

Parameters:

Label-//What to display

colspan-//cross-column display

Td

public string TD(int colspan, string label, string align) table column display style

Parameters:

Label-//What to display

colspan-//cross-column display

Align-//alignment

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.