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.event.eventtype.EventType;
27
28 import org.dbforms.util.Util;
29
30 import javax.servlet.jsp.JspException;
31
32
33
34 /***
35 * <p>
36 * this tag renders a Goto-button.
37 * </p>
38 *
39 * @author Joachim Peer
40 */
41 public class DbGotoButtonTag extends AbstractDbBaseButtonTag
42 implements javax.servlet.jsp.tagext.TryCatchFinally {
43 private String childField;
44 private String destPos;
45 private String destTable;
46 private String destination;
47 private String keyToDestPos;
48 private String keyToKeyToDestPos;
49 private String parentField;
50 private String singleRow = "false";
51
52 /***
53 * DOCUMENT ME!
54 *
55 * @param string
56 */
57 public void setChildField(String string) {
58 childField = string;
59 }
60
61
62 /***
63 * DOCUMENT ME!
64 *
65 * @return
66 */
67 public String getChildField() {
68 return childField;
69 }
70
71
72 /***
73 * DOCUMENT ME!
74 *
75 * @param destPos DOCUMENT ME!
76 */
77 public void setDestPos(String destPos) {
78 this.destPos = destPos;
79 }
80
81
82 /***
83 * DOCUMENT ME!
84 *
85 * @return DOCUMENT ME!
86 */
87 public String getDestPos() {
88 return destPos;
89 }
90
91
92 /***
93 * DOCUMENT ME!
94 *
95 * @param destTable DOCUMENT ME!
96 */
97 public void setDestTable(String destTable) {
98 this.destTable = destTable;
99 }
100
101
102 /***
103 * DOCUMENT ME!
104 *
105 * @return DOCUMENT ME!
106 */
107 public String getDestTable() {
108 return destTable;
109 }
110
111
112 /***
113 * DOCUMENT ME!
114 *
115 * @param destination DOCUMENT ME!
116 */
117 public void setDestination(String destination) {
118 this.destination = destination;
119 }
120
121
122 /***
123 * DOCUMENT ME!
124 *
125 * @return DOCUMENT ME!
126 */
127 public String getDestination() {
128 return destination;
129 }
130
131
132 /***
133 * DOCUMENT ME!
134 *
135 * @param keyToDestPos DOCUMENT ME!
136 */
137 public void setKeyToDestPos(String keyToDestPos) {
138 this.keyToDestPos = keyToDestPos;
139 }
140
141
142 /***
143 * DOCUMENT ME!
144 *
145 * @return DOCUMENT ME!
146 */
147 public String getKeyToDestPos() {
148 return keyToDestPos;
149 }
150
151
152 /***
153 * DOCUMENT ME!
154 *
155 * @param keyToKeyToDestPos DOCUMENT ME!
156 */
157 public void setKeyToKeyToDestPos(String keyToKeyToDestPos) {
158 this.keyToKeyToDestPos = keyToKeyToDestPos;
159 }
160
161
162 /***
163 * DOCUMENT ME!
164 *
165 * @return DOCUMENT ME!
166 */
167 public String getKeyToKeyToDestPos() {
168 return keyToKeyToDestPos;
169 }
170
171
172 /***
173 * DOCUMENT ME!
174 *
175 * @param string
176 */
177 public void setParentField(String string) {
178 parentField = string;
179 }
180
181
182 /***
183 * DOCUMENT ME!
184 *
185 * @return
186 */
187 public String getParentField() {
188 return parentField;
189 }
190
191
192 /***
193 * DOCUMENT ME!
194 *
195 * @param string
196 */
197 public void setSingleRow(String string) {
198 singleRow = string;
199 }
200
201
202 /***
203 * DOCUMENT ME!
204 *
205 * @return the attribute
206 */
207 public String getSingleRow() {
208 return singleRow;
209 }
210
211
212 /***
213 * DOCUMENT ME!
214 */
215 public void doFinally() {
216 destination = null;
217 destTable = null;
218 destPos = null;
219 keyToDestPos = null;
220 keyToKeyToDestPos = null;
221 singleRow = "false";
222 super.doFinally();
223 }
224
225
226 /***
227 * DOCUMENT ME!
228 *
229 * @return DOCUMENT ME!
230 *
231 * @throws javax.servlet.jsp.JspException DOCUMENT ME!
232 * @throws JspException DOCUMENT ME!
233 */
234 public int doStartTag() throws javax.servlet.jsp.JspException {
235 super.doStartTag();
236
237 try {
238 String tagName = EventType.EVENT_NAVIGATION_TRANSFER_GOTO
239 + ((getTable() != null) ? getTable()
240 .getId()
241 : (-1)) + "_"
242 + Integer.toString(getUniqueID());
243
244 StringBuffer tagBuf = new StringBuffer();
245
246
247
248
249 if (destination != null) {
250 tagBuf.append(getDataTag(tagName, "fu", destination));
251 }
252
253 if (destTable != null) {
254 tagBuf.append(getDataTag(tagName, "destTable", destTable));
255 }
256
257
258
259
260 tagBuf.append(getDataTag(tagName, "destPos", destPos));
261 tagBuf.append(getDataTag(tagName, "keyToDestPos",
262 Util.encode(keyToDestPos,
263 pageContext.getRequest().getCharacterEncoding())));
264 tagBuf.append(getDataTag(tagName, "keyToKeyToDestPos",
265 Util.encode(keyToKeyToDestPos,
266 pageContext.getRequest().getCharacterEncoding())));
267
268
269 if ((getConfig()
270 .getTableByName(destTable) != getTable())
271 && (getParentForm()
272 .getTable() != null)) {
273 tagBuf.append(getDataTag(tagName, "srcTable",
274 getParentForm().getTable().getName()));
275 tagBuf.append(getDataTag(tagName, "childField",
276 Util.encode(childField,
277 pageContext.getRequest().getCharacterEncoding())));
278 tagBuf.append(getDataTag(tagName, "parentField",
279 Util.encode(parentField,
280 pageContext.getRequest().getCharacterEncoding())));
281 }
282
283 tagBuf.append(getDataTag(tagName, "singleRow", getSingleRow()));
284
285 tagBuf.append(getButtonBegin());
286 tagBuf.append(" name=\"");
287 tagBuf.append(tagName);
288 tagBuf.append(getButtonEnd());
289
290 pageContext.getOut()
291 .write(tagBuf.toString());
292 } catch (java.io.IOException ioe) {
293 throw new JspException("IO Error: " + ioe.getMessage());
294 }
295
296 if (getChoosenFlavor() == FLAVOR_MODERN) {
297 return EVAL_BODY_BUFFERED;
298 } else {
299 return SKIP_BODY;
300 }
301 }
302 }