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.Field;
27
28 import org.dbforms.util.Util;
29
30 import javax.servlet.jsp.JspException;
31
32
33
34 /***
35 * <p>
36 * renders a input field for searching with special default search modes.
37 * </p>
38 *
39 * <p>
40 * example:
41 * </p>
42 * <input type="hidden" name="searchalgo_0_1" value="weakEnd"/> <input
43 * type="hidden" name="searchmode_0_1" value="AND"/> <input type="text"
44 * name="search_0_1"/> searchalgo and searchmode are set by parameter.
45 *
46 * @author Henner Kollmann
47 */
48 public class DbSearchCheckBoxTag extends DbSearchTag
49 implements javax.servlet.jsp.tagext.TryCatchFinally {
50 private String checked = "false";
51 private String value = null;
52
53 /***
54 * DOCUMENT ME!
55 *
56 * @param string
57 */
58 public void setChecked(String string) {
59 checked = string;
60 }
61
62
63 /***
64 * DOCUMENT ME!
65 *
66 * @return
67 */
68 public String getChecked() {
69 return checked;
70 }
71
72
73 /***
74 * DOCUMENT ME!
75 *
76 * @param string
77 */
78 public void setValue(String string) {
79 value = string;
80 }
81
82
83 /***
84 * DOCUMENT ME!
85 *
86 * @return
87 */
88 public String getValue() {
89 return value;
90 }
91
92 /***
93 * DOCUMENT ME!
94 *
95 * @return DOCUMENT ME!
96 *
97 * @throws javax.servlet.jsp.JspException DOCUMENT ME!
98 * @throws JspException DOCUMENT ME!
99 */
100 public int doEndTag() throws javax.servlet.jsp.JspException {
101 try {
102 Field field = getField();
103
104
105
106
107
108
109 StringBuffer tagBuf = new StringBuffer();
110
111 StringBuffer paramNameBuf = new StringBuffer();
112 paramNameBuf.append(field.getSearchFieldName());
113
114 tagBuf.append("<input type=\"checkbox\" name=\"");
115 tagBuf.append(paramNameBuf.toString());
116 tagBuf.append("\" ");
117 tagBuf.append("value=\"");
118 tagBuf.append(getValue());
119
120 if (Util.getTrue(getChecked())) {
121 tagBuf.append("\" checked=\"checked");
122 }
123
124 tagBuf.append("\"");
125 tagBuf.append(prepareStyles());
126 tagBuf.append(prepareEventHandlers());
127 tagBuf.append("/>\n");
128
129 pageContext.getOut()
130 .write(renderPatternHtmlInputField());
131 pageContext.getOut()
132 .write(RenderHiddenFields(field));
133 pageContext.getOut()
134 .write(tagBuf.toString());
135 } catch (java.io.IOException ioe) {
136 throw new JspException("IO Error: " + ioe.getMessage());
137 }
138
139 return EVAL_PAGE;
140 }
141
142
143 /***
144 * DOCUMENT ME!
145 */
146 public void doFinally() {
147 checked = "false";
148 value = null;
149 super.doFinally();
150 }
151 }