0,0 → 1,64 |
package ak.hostadmiral.core.taglib.list; |
|
import javax.servlet.http.HttpServletRequest; |
import javax.servlet.jsp.JspException; |
import javax.servlet.jsp.tagext.Tag; |
import org.apache.struts.taglib.html.LinkTag; |
import ak.backpath.BackPath; |
import ak.hostadmiral.util.CollectionInfo; |
|
public class PageLinkTag |
extends LinkTag |
{ |
public static String BACKPATH_KEY = BackPath.DEFAULT_KEY + "_list"; |
public static String PAGE_PARAM_NAME = "pg"; |
|
protected PageIterateTag parent; |
|
protected void findParent() |
throws JspException |
{ |
Tag p = getParent(); |
|
while(p != null && !(p instanceof PageIterateTag)) |
p = p.getParent(); |
|
if(p == null) |
throw new JspException("This tag must be inside PageIterateTag"); |
|
parent = (PageIterateTag)p; |
} |
|
protected BackPath findBackPath() |
throws JspException |
{ |
try { |
return BackPath.findBackPath((HttpServletRequest)pageContext.getRequest(), |
BACKPATH_KEY, BackPath.DEFAULT_PARAM, |
new String[] { "backpath", PAGE_PARAM_NAME }, |
BackPath.DEFAULT_ZIP); |
} |
catch(Exception ex) { |
throw new JspException(ex); |
} |
} |
|
protected String calculateURL() |
throws JspException |
{ |
String urlStr = findBackPath().getCurrentUrl(); |
if(urlStr == null) return "/"; |
|
StringBuffer url = new StringBuffer(urlStr); |
boolean hasParams = (url.indexOf("?") > 0); |
|
findParent(); |
|
if(hasParams) |
url.append("&").append(PAGE_PARAM_NAME + "=").append(parent.getDisplayPage()); |
else |
url.append("?").append(PAGE_PARAM_NAME + "=").append(parent.getDisplayPage()); |
|
return url.toString(); |
} |
} |