Java Web page-Common paging component __web

Source: Internet
Author: User
Tags tagname java web

Common Paging components

Sometimes it's a pain to find the right Web page paging component, either there is no fully encapsulated paging method, the use of more cumbersome, inconvenient, or easy to use, but it is difficult to combine with the project, there are many open source paging components, the function is very powerful, but the use of a lot of problems, Some bad with the system, some bad expansion, but the total feeling a little puffy, a lot of functional not practical, also not much significance, this attempt to write a paging component, enough, but also have a lot of problems, hope that everyone to revise together.

1, HTML element java encapsulation:

For ease of operation,

package Commons.page;

import java.util.ArrayList;

import Java.util.HashMap;

import java.util.List;

import Java.util.Map;

import Java.util.Set;

import java.util.Map.Entry;

Public class HtmlElement {

Private String TagName;

Private map<string, string> attributes = new hashmap<string, string> ();

Private listNew arraylist

Private String value = "";

Private String text = "";

Public HtmlElement (String tagName) {

this. tagName = TagName;

}

Public void SetValue (String value) {

this. Value = value;

}

Public List

return children;

}

Public void AddChild (htmlelement Element) {

this. Children.add (element);

}

Public void AddAttribute (string name, String value) {

this. Attributes.put (name, value);

}

Public String Getattributevalue (string name) {

return this. Attributes.get (name);

}

@Override

Public String toString () {

return this. toHtml ();

}

Public String toHtml () {

StringBuffer sb = new stringbuffer ();

Sb.append ("<");

Sb.append (this. tagName);

Sb.append (this. getAttr ());

Sb.append (">");

Sb.append (this. value);

for (HtmlElement e: this. Children) {

Sb.append (e.tohtml ());

}

Sb.append (this. text);

Sb.append ("</");

Sb.append (this. tagName);

Sb.append (">");

return sb.tostring ();

}

protected String getAttr () {

StringBuffer sb = new stringbuffer ();

set<entry<string, string>> attr = this. Attributes.entryset ();

for (entry<string, string> entry:attr) {

Sb.append ("");

Sb.append (Entry.getkey ());

Sb.append ("=/");

Sb.append (Entry.getvalue ());

&

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.