1 7 package org.ejtools.servlet.http.jsp.tagext.iteration; 8 9 import javax.servlet.jsp.JspException ; 10 import javax.servlet.jsp.tagext.BodyTagSupport ; 11 12 import org.apache.struts.util.RequestUtils; 13 14 23 public class NextPageTag extends BodyTagSupport 24 { 25 26 protected String current = null; 27 28 protected String length = null; 29 30 protected String scope = null; 31 32 protected String size = null; 33 34 35 41 public int doStartTag() 42 throws JspException 43 { 44 int currentPage = ((Integer ) RequestUtils.lookup(pageContext, current, scope)).intValue(); 45 int contentSize = ((Integer ) RequestUtils.lookup(pageContext, size, scope)).intValue(); 46 int pageLength = Integer.parseInt(length); 47 48 int lastPage = (contentSize / pageLength); 50 if ((contentSize % pageLength) > 0) 51 { 52 lastPage++; 53 } 54 55 if ((lastPage > 1) && (currentPage < lastPage)) 56 { 57 return (EVAL_BODY_INCLUDE); 58 } 59 return (SKIP_BODY); 60 } 61 62 63 71 public String getCurrent() 72 { 73 return current; 74 } 75 76 77 85 public String getLength() 86 { 87 return length; 88 } 89 90 91 99 public String getScope() 100 { 101 return (this.scope); 102 } 103 104 105 113 public String getSize() 114 { 115 return size; 116 } 117 118 119 120 public void release() 121 { 122 super.release(); 123 size = null; 124 current = null; 125 } 126 127 128 133 public void setCurrent(String current) 134 { 135 this.current = current; 136 } 137 138 139 144 public void setLength(String length) 145 { 146 this.length = length; 147 } 148 149 150 155 public void setScope(String scope) 156 { 157 this.scope = scope; 158 } 159 160 161 166 public void setSize(String size) 167 { 168 this.size = size; 169 } 170 } 171 172 | Popular Tags |