| 1 18 19 package cowsultants.itracker.web.taglib; 20 21 import java.net.*; 22 import javax.servlet.*; 23 import javax.servlet.http.*; 24 import javax.servlet.jsp.JspException ; 25 import javax.servlet.jsp.tagext.BodyTagSupport ; 26 27 import org.apache.struts.Globals; 28 import org.apache.struts.action.*; 29 import org.apache.struts.util.*; 30 31 public final class FormatPaginationLinkTag extends BodyTagSupport { 32 private String text = null; 33 34 private String order = null; 35 private String page = null; 36 private Integer projectId = null; 37 private int start = 0; 38 private String styleClass = null; 39 40 public String getOrder() { 41 return order; 42 } 43 44 public void setOrder(String value) { 45 order = value; 46 } 47 48 public String getPage() { 49 return page; 50 } 51 52 public void setPage(String value) { 53 page = value; 54 } 55 56 public Integer getProjectId() { 57 return projectId; 58 } 59 60 public void setProjectId(Integer value) { 61 projectId = value; 62 } 63 64 public int getStart() { 65 return start; 66 } 67 68 public void setStart(int value) { 69 start = value; 70 } 71 72 public String getStyleClass() { 73 return styleClass; 74 } 75 76 public void setStyleClass(String value) { 77 styleClass = value; 78 } 79 80 public int doStartTag() throws JspException { 81 StringBuffer buf = new StringBuffer ("<a HREF=\""); 82 try { 83 buf.append(RequestUtils.computeURL(pageContext, null, null, page, null, null, null, false)); 84 } catch(MalformedURLException murle) { 85 buf.append(page); 86 } 87 buf.append("?start=" + start); 88 if(projectId != null) { 89 buf.append("&pid=" + projectId); 90 } 91 if(order != null || ! order.equals("")) { 92 buf.append("&order=" + order); 93 } 94 buf.append("\""); 95 if(styleClass != null) { 96 buf.append("class=\"" + styleClass + "\""); 97 } 98 buf.append(">"); 99 ResponseUtils.write(pageContext, buf.toString()); 100 text = null; 101 return (EVAL_BODY_BUFFERED); 102 } 103 104 public int doAfterBody() throws JspException { 105 if (bodyContent != null) { 106 String value = bodyContent.getString().trim(); 107 if (value.length() > 0) { 108 text = value; 109 } 110 } 111 return (SKIP_BODY); 112 } 113 114 public int doEndTag() throws JspException { 115 StringBuffer results = new StringBuffer (); 116 if (text != null) { 117 results.append(text); 118 } 119 results.append("</a>"); 120 ResponseUtils.write(pageContext, results.toString()); 121 clearState(); 122 return (EVAL_PAGE); 123 } 124 125 public void release() { 126 super.release(); 127 clearState(); 128 } 129 130 private void clearState() { 131 text = null; 132 order = null; 133 page = null; 134 projectId = null; 135 start = 0; 136 styleClass = null; 137 } 138 } 139 | Popular Tags |