分页按钮文字国际化
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.nis.domain;
|
package com.nis.domain;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -10,6 +11,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import javax.servlet.http.Cookie;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
@@ -58,6 +60,13 @@ public class Page<T> {
|
|||||||
|
|
||||||
private String message = ""; // 设置提示消息,显示在“共n条”之后
|
private String message = ""; // 设置提示消息,显示在“共n条”之后
|
||||||
|
|
||||||
|
private String prevPage="previousPage";
|
||||||
|
private String nextPage="nextPage";
|
||||||
|
private String currentPage="current";
|
||||||
|
private String TotalCount="Total";
|
||||||
|
private String pageEn="page";
|
||||||
|
private String countPage="count";
|
||||||
|
|
||||||
public Page() {
|
public Page() {
|
||||||
this.pageSize = -1;
|
this.pageSize = -1;
|
||||||
}
|
}
|
||||||
@@ -68,9 +77,21 @@ public class Page<T> {
|
|||||||
* @param response 用于设置 Cookie,记住页码
|
* @param response 用于设置 Cookie,记住页码
|
||||||
*/
|
*/
|
||||||
public Page(HttpServletRequest request, HttpServletResponse response){
|
public Page(HttpServletRequest request, HttpServletResponse response){
|
||||||
|
|
||||||
this(request, response, Integer.valueOf(Configurations.getIntProperty("page.pageSize", 30)));
|
this(request, response, Integer.valueOf(Configurations.getIntProperty("page.pageSize", 30)));
|
||||||
|
|
||||||
|
try {
|
||||||
|
if(CookieUtil.getValue(request, "Language").equalsIgnoreCase("zh_cn")){
|
||||||
|
prevPage="上一页";
|
||||||
|
nextPage="下一页";
|
||||||
|
currentPage="当前";
|
||||||
|
TotalCount="共";
|
||||||
|
pageEn="页";
|
||||||
|
countPage="条";
|
||||||
|
}
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public Page(HttpServletRequest request, HttpServletResponse response,String alias){
|
public Page(HttpServletRequest request, HttpServletResponse response,String alias){
|
||||||
|
|
||||||
@@ -315,9 +336,9 @@ public class Page<T> {
|
|||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if (pageNo == first) {// 如果是首页
|
if (pageNo == first) {// 如果是首页
|
||||||
sb.append("<li class=\"disabled\"><a href=\"javascript:\">« 上一页</a></li>\n");
|
sb.append("<li class=\"disabled\"><a href=\"javascript:\">« "+prevPage+"</a></li>\n");
|
||||||
} else {
|
} else {
|
||||||
sb.append("<li><a href=\"javascript:\" onclick=\""+funcName+"("+prev+","+pageSize+",'"+funcParam+"');\">« 上一页</a></li>\n");
|
sb.append("<li><a href=\"javascript:\" onclick=\""+funcName+"("+prev+","+pageSize+",'"+funcParam+"');\">« "+prevPage+"</a></li>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int begin = pageNo - (length / 2);
|
int begin = pageNo - (length / 2);
|
||||||
@@ -368,18 +389,18 @@ public class Page<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pageNo == last) {
|
if (pageNo == last) {
|
||||||
sb.append("<li class=\"disabled\"><a href=\"javascript:\">下一页 »</a></li>\n");
|
sb.append("<li class=\"disabled\"><a href=\"javascript:\">"+nextPage+" »</a></li>\n");
|
||||||
} else {
|
} else {
|
||||||
sb.append("<li><a href=\"javascript:\" onclick=\""+funcName+"("+next+","+pageSize+",'"+funcParam+"');\">"
|
sb.append("<li><a href=\"javascript:\" onclick=\""+funcName+"("+next+","+pageSize+",'"+funcParam+"');\">"
|
||||||
+ "下一页 »</a></li>\n");
|
+ ""+nextPage+" »</a></li>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append("<li class=\"disabled controls\"><a href=\"javascript:\">当前 ");
|
sb.append("<li class=\"disabled controls\"><a href=\"javascript:\">"+currentPage+" ");
|
||||||
sb.append("<input type=\"text\" value=\""+pageNo+"\" onkeypress=\"var e=window.event||this;var c=e.keyCode||e.which;if(c==13)");
|
sb.append("<input type=\"text\" value=\""+pageNo+"\" onkeypress=\"var e=window.event||this;var c=e.keyCode||e.which;if(c==13)");
|
||||||
sb.append(funcName+"(this.value,"+pageSize+",'"+funcParam+"');\" onclick=\"this.select();\"/> / ");
|
sb.append(funcName+"(this.value,"+pageSize+",'"+funcParam+"');\" onclick=\"this.select();\"/> / ");
|
||||||
sb.append("<input type=\"text\" value=\""+last+"\" onkeypress=\"var e=window.event||this;var c=e.keyCode||e.which;if(c==13)");
|
sb.append("<input type=\"text\" value=\""+last+"\" onkeypress=\"var e=window.event||this;var c=e.keyCode||e.which;if(c==13)");
|
||||||
sb.append(funcName+"("+pageNo+",this.value,'"+funcParam+"');\" onclick=\"this.select();\"/> 页,");
|
sb.append(funcName+"("+pageNo+",this.value,'"+funcParam+"');\" onclick=\"this.select();\"/> "+pageEn+",");
|
||||||
sb.append("共 <span id='showTotalCount'>" + count + "</span> 条"+(message!=null?message:"")+"</a></li>\n");
|
sb.append(""+TotalCount+" <span id='showTotalCount'>" + count + "</span> "+countPage+""+(message!=null?message:"")+"</a></li>\n");
|
||||||
|
|
||||||
sb.insert(0,"<ul>\n").append("</ul>\n");
|
sb.insert(0,"<ul>\n").append("</ul>\n");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user