About the JUI Framework Java Web page refresh feature implementation!

Source: Internet
Author: User

JSP page Part code:

Head:

1 <%@ Page Language= "java" contentType    pageencoding= "UTF-8"%> 3 4 <%@ taglib Prefix= "s" uri= "/struts-tags"%> 5 <%@ Page iselignored= "false"%> 6 <form id= " Pagerform "method=" post "action=" Infor/name.do "> 7 <input type=" hidden "name=" Pagenum "value=" 1 "/> 8 <input Type= "hidden" name= "Numperpage" value= "${numperpage}"/> 9 <input type= "hidden" name= "OrderField" value= "${ OrderField} "/>10 <input type=" hidden "name=" orderdirection "value=" ${orderdirection} "/>11 </form> 

Table section:

1 <tbody> 2         <s:iterator  value = "List" > 3             <tr target= "Sid_user" rel= "1" > 4                 <TD ><input type= "checkbox" Name= "IDs" value= "${id}"/></td> 5                 <td>${nameID}</td> 6                 <td>${name}</td> 7                 <td>${moddate}</td> 8                 <td>${modmanID}</td> 9                 <td>${modmanname}</td>10                 <td>11                     <a title= "edit" target= "dialog" href= "infor/ Editorname.do?flag=${id} "class=" Btnedit "rel=" Editorname "> Edit </a>12                 </td>13             </tr>             </s:iterator>15         </tbody>

Bottom page Pagination section:

 1 <div class= "Panelbar" > 2 <div class= "pages" > 3 <span> per page </span> 4                 <select class= "Combox" name= "Numperpage" onchange= "Navtabpagebreak ({numPerPage:this.value})" > 5                  <option <s:if test= "numperpage==1" >selected= "selected" </s:if> value= "1" >1</option> 6 7 <option <s:if test= "numperpage==20" >selected= "selected" </s:if> value= "&GT;20&L" T;/option> 8 <option <s:if test= "numperpage==50" >selected= "selected" </s:if> value= "&G" T;50</option> 9 <option <s:if test= "numperpage==100" >selected= "selected" </s:if> value = ">100</option>10" <option <s:if test= "numperpage==200" >selected= "selected" </s:if& Gt          Value= "$" >200</option>11 </select>12 <span>, Total ${totalcount} strip </span>13 </div> <div class= "pagination" targettype= "${targettype}" totalcount= "${totalcount}" numperpage= "${numPerPage}" pa Genumshown= "currentpage=" ${pagenum} "></div>15 </div>

XML configuration jump (this is not necessary for reference):

<action name= "name" class= "Com.threegrand.www.information.action.Name" method= "name" >            <result  Name= "SUCCESS" >/content/information/name.jsp</result>        </action>

Action Layer:

1 ImportJava.util.List; 2 ImportJava.util.Map; 3 4 ImportJavax.servlet.http.HttpServletRequest; 5 6 ImportOrg.apache.struts2.ServletActionContext; 7 8 ImportCom.opensymphony.xwork2.ActionSupport; 9 ImportCom.threegrand.www.information.service.NameService; Ten public class Name extendsactionsupport {Nameservice SE = newNameservice (); Private List<map<string, object>>List PrivateString name; PrivateString specimen; + PrivateString NameID; PrivateString moddate; PrivateString Modmanid; PrivateString Modmanname; PublicNameservice Getse () {returnSe 23} public voidSetse (Nameservice se) {this.se =Se 26} publicString GetName () {-ReturnName 29} public voidSetName (String name) {this.name =Name 32} list<map<string, object>>GetList () {returnList 35}-public void setlist (list<map<string, object>>List) {PNs This.list =List 38}String Getspecimen () {returnspecimen; 41} public voidSetspecimen (String specimen) {this.specimen =specimen; 44} publicString Getnameid () {returnNameID; 47}-public voidSetnameid (String nameID) {This.nameid =NameID; 50} publicString getmoddate () {returnModdate; 53} The public voidSetmoddate (String moddate) {this.moddate =Moddate; 56}String Getmodmanid () {.Modmanid; 59} public voidSetmodmanid (String modmanid) {This.modmanid =Modmanid; 62}String Getmodmanname () {Modmanname; 65} The public voidSetmodmanname (String modmanname) {this.modmanname =Modmanname; 68} 69 70/* 71 * Paging Refresh * * * * * * * * * * * * * * * private String LoginName = ""; Private Integer Pagenum=1; CurrentPage private Integer = 1; Current is the first few pages of the private String targettype= "Navtab"; Navtab or dialog, which is used to mark the pagination on the Navtab or the pagination on the dialog of the private Integer totalcount=0; Total article number of the private Integer numperpage=20; Each page shows how many BA private Integer pagenumshown=10; Page label number How many of the private Integer PageCount = 0; Total pages of the privateString OrderField; PrivateString orderdirection; PublicString Getloginname () {* * * returnLoginName; 87} The public voidSetloginname (String loginName) {this.loginname =LoginName; 90} publicInteger Getpagenum () {returnPagenum; 93} 94 public voidSetpagenum (Integer pagenum) {this.pagenum =Pagenum; 96}Integer Getcurrentpage () {98 returnCurrentPage; 99}100 public voidSetcurrentpage (Integer currentpage) {101 This.currentpage =currentpage;102}103 PublicString Gettargettype () {104 returntargettype;105}106 public voidSettargettype (String targetType) {107 This.targettype =targettype;108}109 PublicInteger Gettotalcount () {returntotalcount;111}112 public voidSettotalcount (Integer totalcount) {113 This.totalcount =totalcount;114}115 PublicInteger Getnumperpage () {returnnumperpage;117}118 public voidSetnumperpage (Integer numperpage) {119 This.numperpage =numperpage;120}121 PublicInteger Getpagenumshown () {122 returnPagenumshown;123}124 public voidSetpagenumshown (Integer pagenumshown) {This.pagenumshown =pagenumshown;126}127 PublicInteger Getpagecount () {$ returnpagecount;129}130 public voidSetpagecount (Integer pagecount) {131 This.pagecount = pagecount;132 }133 public  String Getorderfield () {134 return  orderfield;135 }136 Public v OID  Setorderfield (string OrderField) {137 This.orderfield =  orderfield;138 }139 public  string GE Torderdirection () { orderdirection;141 }142 public void  setorderdirection (String Orderdirection) {143 this.orderdirection =  orderdirection;144 }145 146 public  String Name () {147  Page (); 148 list=  se.pagination (loginname,pagenum,numperpage,orderfield,orderdirection); 149 return "SUCCESS" ; 151 }: public void  page () {153 TotalCount =  se.getcout (loginName); 154 PageCount = Totalco Unt% Numperpage = = 0? Totalcount/numperpage:totalcount/numperpage + 1 ; 155 }156 157        

Service Layer:

1 ImportJava.sql.Connection; 2 ImportJava.sql.PreparedStatement; 3 ImportJava.sql.ResultSet; 4 ImportJava.sql.SQLException; 5 ImportJava.util.ArrayList; 6 ImportJava.util.List; 7 ImportJava.util.Map; 8 9 ImportJAVAX.SERVLET.HTTP.HTTPSERVLETREQUEST;10 ImportORG.APACHE.STRUTS2.SERVLETACTIONCONTEXT;11 ImportCOM.THREEGRAND.WWW.UTILS.DBUTIL;12 public classNameservice {Dbutil db = newDbutil (); list<map<string,object>>list;16/*17 * Page Refresh * */20 + Connection Conn=null; Private PreparedStatement Ps=null; all private ResultSet rs=null;Integer getcout (String name) {count=0 int; try{sql= String "select COUNT (1) from name where 1=1 and name is like?"; conn=Db.getconnection (); ps=Conn.preparestatement (SQL); ps.setstring (1, "%" +name+ "%"); rs=Ps.executequery ();(Rs.next ()) {Count=rs.getint (1); 35}36 PNS} catch(SQLException e) {38E.printstacktrace ();}finally{Try{if (rs! = null) {42Rs.close (); 43}44 if (PS! = null) {45Ps.close (); 46}47 if (conn! = null ) {$  conn.close (); }50} catch  (SQLException e) {Wuyi  e.print StackTrace (); }53 }54 return  count;55 }56 public list<map<string, Object>>  Pagination (string Name,integer currentpage,integer numperpage,string orderfield,string orderDirection) {. Sql= "Select Id,specimen,nameid,name,moddate,modmanid,modmanname from name WHERE name like ' percent ' limit" + (currentPage-1) * Numperpage + "," +  numperpage;59 if (orderfield!=null&&! "" . Equals (OrderField)) {sql= "select Id,specimen,nameid,name,moddate,modmanid,modmanname from name WHERE name is like '%" order BY "+orderfield+ "" +orderdirection+ "Limit" + (currentPage-1) *numperpage + "," +  numperpage;61 }63 + list=  Db.querytolist (SQL); return  list;67}70         

The above content is also my reference to other sources of code as a reference to write, may not be fully understood, but the comparison of human code to simplify, removed the DAO layer and model layer.

Attached database content:

Here are the following:

About the JUI Framework Java Web page refresh feature implementation!

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.