1 7 package org.ejtools.servlet.http.jsp.tagext.iteration; 8 9 import javax.servlet.jsp.JspException ; 10 import javax.servlet.jsp.tagext.TagSupport ; 11 12 import org.apache.struts.util.RequestUtils; 13 import org.apache.struts.util.ResponseUtils; 14 15 24 public class CurrentPageTag extends TagSupport 25 { 26 27 protected String current = null; 28 29 protected String length = null; 30 31 protected String scope = null; 32 33 protected String size = null; 34 35 36 42 public int doStartTag() 43 throws JspException 44 { 45 int currentPage = ((Integer ) RequestUtils.lookup(pageContext, current, scope)).intValue(); 46 int contentSize = ((Integer ) RequestUtils.lookup(pageContext, size, scope)).intValue(); 47 int pageLength = Integer.parseInt(length); 48 49 int lastPage = (contentSize / pageLength); 51 if ((contentSize % pageLength) > 0) 52 { 53 lastPage++; 54 } 55 if (lastPage == 0) 56 { 57 lastPage = 1; 58 } 59 60 StringBuffer output = new StringBuffer (); 61 output.append(currentPage); 62 output.append("/"); 63 output.append(lastPage); 64 65 ResponseUtils.write(pageContext, output.toString()); 66 67 return (SKIP_BODY); 69 } 70 71 72 80 public String getCurrent() 81 { 82 return current; 83 } 84 85 86 94 public String getLength() 95 { 96 return length; 97 } 98 99 100 108 public String getScope() 109 { 110 return (this.scope); 111 } 112 113 114 122 public String getSize() 123 { 124 return size; 125 } 126 127 128 129 public void release() 130 { 131 super.release(); 132 size = null; 133 current = null; 134 } 135 136 137 142 public void setCurrent(String current) 143 { 144 this.current = current; 145 } 146 147 148 153 public void setLength(String length) 154 { 155 this.length = length; 156 } 157 158 159 164 public void setScope(String scope) 165 { 166 this.scope = scope; 167 } 168 169 170 175 public void setSize(String size) 176 { 177 this.size = size; 178 } 179 180 } 181 182 | Popular Tags |