Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 1026 → Rev 1027

/hostadmiral/trunk/src/ak/hostadmiral/core/taglib/list/PageIterateTag.java
0,0 → 1,96
package ak.hostadmiral.core.taglib.list;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
import org.apache.struts.util.RequestUtils;
import org.apache.struts.util.ResponseUtils;
import ak.hostadmiral.util.CollectionInfo;
 
public class PageIterateTag
extends BodyTagSupport
{
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 int displayPage;
 
public int getDisplayPage()
{
return this.displayPage;
}
 
protected CollectionInfo collectionInfo;
 
public CollectionInfo getCollectionInfo()
{
return this.collectionInfo;
}
 
public int doStartTag() throws JspException
{
displayPage = 0;
collectionInfo = findCollectionInfo();
 
if(collectionInfo == null) return SKIP_BODY;
 
if(collectionInfo.getTotalPages() > 0)
return EVAL_BODY_TAG;
else
return SKIP_BODY;
}
 
public int doAfterBody() throws JspException
{
// Render the output from this iteration to the output stream
if(bodyContent != null) {
ResponseUtils.writePrevious(pageContext, bodyContent.getString());
bodyContent.clearBody();
}
 
if(++displayPage < collectionInfo.getTotalPages())
return EVAL_BODY_TAG;
else
return SKIP_BODY;
}
 
public int doEndTag() throws JspException
{
return EVAL_PAGE;
}
 
protected CollectionInfo findCollectionInfo()
throws JspException
{
return (CollectionInfo)
RequestUtils.lookup(pageContext, infoBean, infoProperty, null);
}
 
public void release()
{
super.release();
infoBean = null;
infoProperty = null;
}
}