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 javax.servlet.jsp.*;
27
28
29
30 /***
31 * <p>
32 * This tag enables the end-user to define a row by selecting the radio-button
33 * rendered by this tag
34 * </p>
35 *
36 * <p>
37 * This tag enables the end-user to define a row by selecting the radio-button
38 * rendered by this tag
39 * </p>
40 * <tagclass>org.dbforms.taglib.DbAssociatedRadioTag</tagclass>
41 * <bodycontent>empty</bodycontent>
42 *
43 * <p>
44 * example: imagine a table customer, which should be listed. the user should
45 * be able to delete a customer.
46 * </p>
47 * in that case the application developer has to alternatives: to put a
48 * "deleteButton" into the body -> this button gets rendered for every row<br>
49 * if the user klicks the button the associated data row gets deleted. the
50 * disadvantage of this method is that multiple buttons must be rendered,
51 * which takes away lots of space and makes layouting more difficult to put
52 * an "associatedRadio" into the body and the "deleteButton" on the footer (or header)<br>
53 * the radio element gets rendered for every row, the deleteButton just once.
54 * if the user wants to delete a row, he/she has to select the radioButton (to
55 * mark the row he/she wants to be deleted) and then to press the
56 * deleteButton.
57 *
58 * <p>
59 * the more buttons you have the better this method is!!
60 * </p>
61 *
62 * <p>
63 * nota bene: you have to tell the delete (or insert, update...) - button that
64 * there is an associated radio button that marks the row the action should be
65 * applied to, by defining the "associatedRadio" attribute of that respective
66 * button
67 * </p>
68 *
69 * <p></p>
70 *
71 * @author Joachim Peer
72 */
73 public class DbAssociatedRadioTag extends AbstractDbBaseHandlerTag
74 implements javax.servlet.jsp.tagext.TryCatchFinally {
75 private String name;
76
77 /***
78 * DOCUMENT ME!
79 *
80 * @param name DOCUMENT ME!
81 */
82 public void setName(String name) {
83 this.name = name;
84 }
85
86
87 /***
88 * DOCUMENT ME!
89 *
90 * @return DOCUMENT ME!
91 */
92 public String getName() {
93 return name;
94 }
95
96
97
98 /***
99 * DOCUMENT ME!
100 *
101 * @return DOCUMENT ME!
102 *
103 * @throws javax.servlet.jsp.JspException DOCUMENT ME!
104 * @throws JspException DOCUMENT ME!
105 */
106 public int doEndTag() throws javax.servlet.jsp.JspException {
107 try {
108 StringBuffer tagBuf = new StringBuffer("<input type=\"radio\" name=\"");
109 tagBuf.append(name);
110 tagBuf.append("\" value=\"");
111 tagBuf.append(getParentForm().getTable().getId());
112 tagBuf.append("_");
113 tagBuf.append(getParentForm().getPositionPath());
114
115
116 tagBuf.append("\"");
117
118 if (getParentForm()
119 .getCurrentCount() == 0) {
120 tagBuf.append(" checked=\"true\"");
121 }
122
123 tagBuf.append("/>");
124 pageContext.getOut()
125 .write(tagBuf.toString());
126 } catch (java.io.IOException ioe) {
127 throw new JspException("IO Error: " + ioe.getMessage());
128 }
129
130 return EVAL_PAGE;
131 }
132
133
134 /***
135 * DOCUMENT ME!
136 */
137 public void doFinally() {
138 name = null;
139 super.doFinally();
140 }
141 }