0,0 → 1,87 |
package ak.hostadmiral.core.taglib.list; |
|
import javax.servlet.http.HttpServletRequest; |
import javax.servlet.jsp.JspException; |
import org.apache.struts.taglib.html.LinkTag; |
import org.apache.struts.util.RequestUtils; |
import ak.backpath.BackPath; |
import ak.hostadmiral.util.CollectionInfo; |
|
public abstract class PageTagBase |
extends LinkTag |
{ |
public static String BACKPATH_KEY = BackPath.DEFAULT_KEY + "_list"; |
public static String PAGE_PARAM_NAME = "pg"; |
|
protected String infoBean = null; |
|
public String getInfoBean() |
{ |
return this.infoBean; |
} |
|
public void setInfoBean(String infoBean) |
{ |
this.infoBean = infoBean; |
} |
|
protected String infoProperty = null; |
|
public String getInfoProperty() |
{ |
return this.infoProperty; |
} |
|
public void setInfoProperty(String infoProperty) |
{ |
this.infoProperty = infoProperty; |
} |
|
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); |
|
if(hasParams) |
url.append("&").append(PAGE_PARAM_NAME + "=").append(getDisplayPage()); |
else |
url.append("?").append(PAGE_PARAM_NAME + "=").append(getDisplayPage()); |
|
return url.toString(); |
} |
|
protected abstract int getDisplayPage() |
throws JspException; |
|
protected CollectionInfo getCollectionInfo() |
throws JspException |
{ |
return (CollectionInfo) |
RequestUtils.lookup(pageContext, infoBean, infoProperty, null); |
} |
|
public void release() |
{ |
super.release(); |
infoBean = null; |
infoProperty = null; |
} |
} |