1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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 /***
38 * Grunikiewicz.philip 2001-12-18 Display a custom message if the developer has
39 * set a limit on the number of rows to display
40 */
41 public class HasMoreRecordsTag extends AbstractDbBaseHandlerTag
42 implements javax.servlet.jsp.tagext.TryCatchFinally {
43 private transient DbFormsErrors errors;
44 private String count = null;
45 private String message = null;
46
47 /***
48 * Sets the count
49 *
50 * @param count The count to set
51 */
52 public void setCount(String count) {
53 this.count = count;
54 }
55
56
57 /***
58 * Gets the count
59 *
60 * @return Returns a String
61 */
62 public String getCount() {
63 return count;
64 }
65
66
67 /***
68 * Gets the count as int
69 *
70 * @return DOCUMENT ME!
71 */
72 public int getCountAsInt() {
73 return Integer.parseInt(getCount());
74 }
75
76
77 /***
78 * Sets the message
79 *
80 * @param message The message to set
81 */
82 public void setMessage(String message) {
83 this.message = message;
84 }
85
86
87 /***
88 * Gets the message
89 *
90 * @return Returns a String
91 */
92 public String getMessage() {
93 return message;
94 }
95
96
97 /***
98 * DOCUMENT ME!
99 *
100 * @param pageContext DOCUMENT ME!
101 */
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 * DOCUMENT ME!
110 *
111 * @return DOCUMENT ME!
112 *
113 * @throws javax.servlet.jsp.JspException DOCUMENT ME!
114 * @throws JspException DOCUMENT ME!
115 */
116 public int doEndTag() throws javax.servlet.jsp.JspException {
117
118 try {
119 int rsvSize = getParentForm()
120 .getResultSetVector()
121 .size();
122
123 if (rsvSize >= getCountAsInt()) {
124 if (bodyContent != null) {
125 bodyContent.writeOut(bodyContent.getEnclosingWriter());
126 bodyContent.clearBody();
127 }
128
129 String pmessage = (errors != null)
130 ? errors.getXMLErrorMessage(getMessage())
131 : getMessage();
132
133 if (!Util.isNull(pmessage)) {
134
135 JspWriter writer = pageContext.getOut();
136
137 try {
138 writer.print(pmessage);
139 } catch (IOException e) {
140 throw new JspException(e.toString());
141 }
142 }
143 }
144 } catch (java.io.IOException e) {
145 throw new JspException("IO Error: " + e.getMessage());
146 }
147
148 return EVAL_PAGE;
149 }
150
151
152 /***
153 * DOCUMENT ME!
154 */
155 public void doFinally() {
156 count = null;
157 message = null;
158 errors = null;
159 super.doFinally();
160 }
161
162
163 /***
164 * Render the specified error messages if there are any.
165 *
166 * @return DOCUMENT ME!
167 *
168 * @exception JspException if a JSP exception has occurred
169 */
170 public int doStartTag() throws JspException {
171 int rsvSize = getParentForm()
172 .getResultSetVector()
173 .size();
174
175 if (rsvSize >= getCountAsInt()) {
176 return EVAL_BODY_BUFFERED;
177 } else {
178 return SKIP_BODY;
179 }
180 }
181 }