1 23 24 package org.dbforms.taglib; 25 26 import org.dbforms.config.DbFormsErrors; 27 28 import org.dbforms.util.Util; 29 30 import java.io.IOException ; 31 32 import javax.servlet.jsp.JspException ; 33 import javax.servlet.jsp.JspWriter ; 34 35 36 37 41 public class HasMoreRecordsTag extends DbBaseHandlerTag 42 implements javax.servlet.jsp.tagext.TryCatchFinally { 43 private transient DbFormsErrors errors; 44 private String count = null; 45 private String message = null; 46 47 52 public void setCount(String count) { 53 this.count = count; 54 } 55 56 57 62 public String getCount() { 63 return count; 64 } 65 66 67 72 public int getCountAsInt() { 73 return Integer.parseInt(getCount()); 74 } 75 76 77 82 public void setMessage(String message) { 83 this.message = message; 84 } 85 86 87 92 public String getMessage() { 93 return message; 94 } 95 96 97 102 public void setPageContext(final javax.servlet.jsp.PageContext pageContext) { 103 super.setPageContext(pageContext); 104 this.errors = (DbFormsErrors) pageContext.getServletContext() 105 .getAttribute(DbFormsErrors.ERRORS); 106 } 107 108 109 112 public void doCatch(Throwable t) throws Throwable { 113 throw t; 114 } 115 116 117 125 public int doEndTag() throws javax.servlet.jsp.JspException { 126 try { 128 int rsvSize = getParentForm() 129 .getResultSetVector() 130 .size(); 131 132 if (rsvSize >= getCountAsInt()) { 133 if (bodyContent != null) { 134 bodyContent.writeOut(bodyContent.getEnclosingWriter()); 135 bodyContent.clearBody(); 136 } 137 138 String pmessage = (errors != null) 139 ? errors.getXMLErrorMessage(getMessage()) 140 : getMessage(); 141 142 if (!Util.isNull(pmessage)) { 143 JspWriter writer = pageContext.getOut(); 145 146 try { 147 writer.print(pmessage); 148 } catch (IOException e) { 149 throw new JspException (e.toString()); 150 } 151 } 152 } 153 } catch (java.io.IOException e) { 154 throw new JspException ("IO Error: " + e.getMessage()); 155 } 156 157 return EVAL_PAGE; 158 } 159 160 161 164 public void doFinally() { 165 count = null; 166 message = null; 167 errors = null; 168 super.doFinally(); 169 } 170 171 172 179 public int doStartTag() throws JspException { 180 int rsvSize = getParentForm() 181 .getResultSetVector() 182 .size(); 183 184 if (rsvSize >= getCountAsInt()) { 185 return EVAL_BODY_BUFFERED; 186 } else { 187 return SKIP_BODY; 188 } 189 } 190 } 191 | Popular Tags |