-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
217 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package net.ion.nsearcher.util; | ||
|
||
import net.ion.framework.db.Page; | ||
import net.ion.framework.util.StringUtil; | ||
|
||
public class PageOption { | ||
|
||
private String linkName = "link"; | ||
private String strDepth = "/"; | ||
private String forwardName = "list"; | ||
private boolean showListNum = true ; | ||
private String listCount = "list count" ; | ||
private String countUnit = " unit" ; | ||
|
||
public final static PageOption DEFAULT = new PageOptionBuilder().build() ; | ||
|
||
public PageOption(String linkName, String strDepth, String forwardName, boolean showListNum, String listCount, String countUnit) { | ||
this.linkName = linkName ; | ||
this.strDepth = strDepth ; | ||
this.forwardName = forwardName ; | ||
this.showListNum = showListNum ; | ||
this.listCount = listCount ; | ||
this.countUnit = countUnit ; | ||
} | ||
|
||
|
||
public String toHtml(int rowcount, Page page) { | ||
String goForwardName = StringUtil.isBlank(forwardName) ? "list" : forwardName; | ||
PageOutPut pageout = new PageOutPut(linkName, rowcount, page); | ||
if (pageout.isValidPage()) { | ||
StringBuilder buffer = new StringBuilder(); | ||
buffer.append("<div class='page-box'>"); | ||
|
||
buffer.append("<ol class='pagelist'>"); | ||
buffer.append(pageout.printPagePrev("<li>", "<img src='" + strDepth + "common/button/list_prev.gif' border='0'>", "<img src='" + strDepth + "common/button/list_prev.gif' border='0'>", "</li>", forwardName)); | ||
buffer.append(pageout.printPageNoList(goForwardName)); | ||
buffer.append("<li></li>"); | ||
buffer.append(pageout.printPageNext("<li>", "<img src='" + strDepth + "common/button/list_next.gif' border='0'>", "<img src='" + strDepth + "common/button/list_next.gif' border='0'>", "</li>", forwardName)); | ||
buffer.append("</ol>"); | ||
|
||
if(showListNum) { | ||
buffer.append("<p class='page-num'>" + listCount + " : <input name='listNum' size='5' maxlength='5' onchange='link.changeListNum()' onkeypress='onlyNumber(event)' value='" + page.getListNum() + "'/> "+ countUnit + "</p>"); | ||
} | ||
|
||
buffer.append("</div>"); | ||
|
||
|
||
return buffer.toString(); | ||
} else { | ||
return "<script type=\"text/javascript\">link.goListPage(link.getSelfForm().pageNo.value - 1, '" + goForwardName + "' )</script>"; | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package net.ion.nsearcher.util; | ||
|
||
public class PageOptionBuilder { | ||
|
||
private String linkName = "link"; | ||
private String strDepth = "/"; | ||
private String forwardName = "list"; | ||
private boolean showListNum = true ; | ||
private String listCount = "list count" ; | ||
private String countUnit = " unit" ; | ||
|
||
public String getLinkName() { | ||
return linkName; | ||
} | ||
public String getStrDepth() { | ||
return strDepth; | ||
} | ||
public String getForwardName() { | ||
return forwardName; | ||
} | ||
public boolean isShowListNum() { | ||
return showListNum; | ||
} | ||
public String getListCount() { | ||
return listCount; | ||
} | ||
public String getCountUnit() { | ||
return countUnit; | ||
} | ||
public void setLinkName(String linkName) { | ||
this.linkName = linkName; | ||
} | ||
public void setStrDepth(String strDepth) { | ||
this.strDepth = strDepth; | ||
} | ||
public void setForwardName(String forwardName) { | ||
this.forwardName = forwardName; | ||
} | ||
public void setShowListNum(boolean showListNum) { | ||
this.showListNum = showListNum; | ||
} | ||
public void setListCount(String listCount) { | ||
this.listCount = listCount; | ||
} | ||
public void setCountUnit(String countUnit) { | ||
this.countUnit = countUnit; | ||
} | ||
|
||
public PageOption build(){ | ||
return new PageOption(this.linkName, this.strDepth, this.forwardName, this.showListNum, this.listCount, this.countUnit) ; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package net.ion.nsearcher.util; | ||
|
||
import net.ion.framework.db.Page; | ||
import net.ion.framework.util.StringUtil; | ||
|
||
public class PageOutPut { | ||
private final String linkName; | ||
private final Page page; | ||
private final int rowCount; | ||
|
||
public PageOutPut(String linkName, int rowCount, Page page) { | ||
this.linkName = linkName; | ||
this.page = page; | ||
this.rowCount = rowCount; | ||
} | ||
|
||
public String printPagePrev(String head, String body, String repbody, String tail, String forwardName) { | ||
String result = ""; | ||
|
||
result += head; | ||
if (page.getCurrentScreen() > 1) { | ||
result += "<a href=\"javascript:" + linkName + "." + "goPreScreen(" + page.getPreScreenEndPageNo() + (StringUtil.isBlank(forwardName) ? "" : ", '" + forwardName + "'") + ")\">" + body + "</a>"; | ||
} else { | ||
result += repbody; | ||
} | ||
result += tail; | ||
|
||
return result; | ||
} | ||
|
||
public String printPageNext(String head, String body, String repbody, String tail, String forwardName) { | ||
String result = ""; | ||
|
||
result += head; | ||
// if(listNum * ((screen + 1 ) * ScreenCount) < rowCount) { | ||
//if(listNum * ScreenCount < rowCount) { | ||
if (page.getScreenCount() * page.getListNum() < rowCount ) { | ||
result += " <a href=\"javascript:" + linkName + "." + "goNextScreen(" + page.getNextScreenStartPageNo() + (StringUtil.isBlank(forwardName) ? "" : ", '" + forwardName + "'") + ")\">" + body + "</a>"; | ||
} else { | ||
result += repbody; | ||
} | ||
result += tail; | ||
|
||
return result; | ||
} | ||
|
||
public String printPageNoList() { | ||
return printPageNoList(null); | ||
} | ||
|
||
public String printPageNoList(String forwardName) { | ||
String _forwardName = ""; | ||
if(StringUtil.isNotBlank(forwardName)) { | ||
_forwardName = ", '" + forwardName + "'"; | ||
} | ||
|
||
StringBuffer rtnValue = new StringBuffer(""); | ||
/* | ||
if (page.getPageNo() > 1) | ||
rtnValue.append("<a id=\"n_prev_page\" href=\"javascript:link.goListPage(" + (page.getPageNo() - 1) + _forwardName + ")\"></a>"); | ||
if (page.getPageNo() < page.getMaxPageNo(rowCount)) | ||
rtnValue.append("<a id=\"n_next_page\" href=\"javascript:link.goListPage(" + (page.getPageNo() + 1) + _forwardName + ")\"></a>"); | ||
*/ | ||
for (int startPage = page.getMinPageNoOnScreen(), endPage = Math.min(page.getMaxPageNo(rowCount), page.getMaxPageNoOnScreen()); startPage <= endPage; startPage++) { | ||
if (startPage == page.getPageNo()) | ||
rtnValue.append(" <li class='num'><a class='current'>" + startPage + "</a></li>"); | ||
// rtnValue.append(" <a style='padding: 0 3px 0 3px;' class='current'>" + startPage + "</a>"); | ||
else | ||
rtnValue.append(" <li class='num'><a href=\"javascript:" + linkName + "." + "goListPage(" + startPage + _forwardName + ")\">" + startPage + "</a></li>"); | ||
// rtnValue.append(" <a style='padding: 0 3px 0 3px;' href=\"javascript:" + linkName + "." + "goListPage(" + startPage + _forwardName + ")\">" + startPage + "</a>"); | ||
} | ||
|
||
return rtnValue.toString(); | ||
} | ||
|
||
public boolean isValidPage() { | ||
if (page.getPageNo() > 1 && rowCount == 0) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters