?? pageresulttag.java
字號:
/**
*
*/
package cn.bway.struts.tag;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.struts.util.RequestUtils;
import cn.bway.common.vo.QueryResult;
/**
* @author Kson
*
*/
public class PageResultTag extends TagSupport {
private static final long serialVersionUID = 1L;
private String name;
private String property;
private String scope;
protected final Logger log = LogManager.getLogger(getClass());
public PageResultTag() {
}
public int doStartTag() throws JspTagException {
try {
if (this.scope == null) {
this.scope = "request";
}
Object obj = RequestUtils.lookup(pageContext,name,property,scope);
QueryResult query = (QueryResult) obj;
StringBuffer tmp = new StringBuffer();
tmp.append(" <table width=\"98%\" border=\"0\" class=\"table_2\" cellpadding=\"0\" cellspacing=\"0\">\n");
tmp.append(" <tr>\n");
tmp.append(" <td width=\"98%\" align=\"right\">\n");
tmp.append("共有<font color=\"#FF3333\">"+query.getPageCount()+"</font>頁<font color=\"#FF3333\">"+query.getResultCount()+"</font>條記錄,當前為第<font color=\"#FF3333\">"+query.getPageNum()+"</font>頁\n");
tmp.append(query.getPageNum() >1?" <a href=\"javascript:Page(1)\">第一頁</a>\n":" 第一頁\n");
tmp.append(query.getPageNum() >1?" <a href=\"javascript:Page("+String.valueOf(query.getPageNum()-1)+")\">上一頁</a>\n":" 上一頁\n");
tmp.append((query.getPageNum()==query.getPageCount()||query.getPageCount()<=1)?" 下一頁":" <a href=\"javascript:Page("+String.valueOf(query.getPageNum()+1)+")\">下一頁</a>\n");
tmp.append((query.getPageNum()==query.getPageCount()||query.getPageCount()<=1)?" 最后頁":" <a href=\"javascript:Page("+String.valueOf(query.getPageCount())+")\">最后頁</a>\n");
if(query.getResultCount()!=0){
tmp.append(" 到第<input onkeydown=\"javascript:if(event.keyCode == 13) Page(document.forms[0].currentPageNum.value)\" align=\"center\" type=\"text\" size=\"3\" name=\"currentPageNum\" maxlength=\"5\" value=\""+ query.getPageNum()+"\">頁\n");
tmp.append("<a href=\"javascript:Page(document.forms[0].currentPageNum.value)\" id=\"idGo\" ><img src='images/go.gif' border=\"0\"></a>\n");
}
tmp.append(" </td>\n");
tmp.append(" </tr>\n");
tmp.append(" </table>\n");
pageContext.getOut().print(tmp.toString());
} catch (Exception e) {
log.debug(this.getClass().getName() + ".doStartTag():"
+ e.getMessage());
}
return EVAL_PAGE;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getProperty() {
return property;
}
public void setProperty(String property) {
this.property = property;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -