KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbforms > taglib > DbSearchCheckBoxTag


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/DbSearchCheckBoxTag.java,v 1.6 2004/08/18 12:26:08 hkollmann Exp $
3  * $Revision: 1.6 $
4  * $Date: 2004/08/18 12:26:08 $
5  *
6  * DbForms - a Rapid Application Development Framework
7  * Copyright (C) 2001 Joachim Peer <joepeer@excite.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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 JavaDoc;
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  * &lt;input type="hidden" name="searchalgo_0_1" value="weakEnd"/&gt; &lt;input
43  * type="hidden" name="searchmode_0_1" value="AND"/&gt; &lt;input type="input"
44  * name="search_0_1"/&gt; 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 JavaDoc {
50    private String JavaDoc checked = "false";
51    private String JavaDoc value = null;
52
53    /**
54     * DOCUMENT ME!
55     *
56     * @param string
57     */

58    public void setChecked(String JavaDoc string) {
59       checked = string;
60    }
61
62
63    /**
64     * DOCUMENT ME!
65     *
66     * @return
67     */

68    public String JavaDoc getChecked() {
69       return checked;
70    }
71
72
73    /**
74     * DOCUMENT ME!
75     *
76     * @param string
77     */

78    public void setValue(String JavaDoc string) {
79       value = string;
80    }
81
82
83    /**
84     * DOCUMENT ME!
85     *
86     * @return
87     */

88    public String JavaDoc getValue() {
89       return value;
90    }
91
92
93    /**
94     * @see javax.servlet.jsp.tagext.TryCatchFinally#doCatch(java.lang.Throwable)
95     */

96    public void doCatch(Throwable JavaDoc t) throws Throwable JavaDoc {
97       throw t;
98    }
99
100
101    /**
102     * DOCUMENT ME!
103     *
104     * @return DOCUMENT ME!
105     *
106     * @throws javax.servlet.jsp.JspException DOCUMENT ME!
107     * @throws JspException DOCUMENT ME!
108     */

109    public int doEndTag() throws javax.servlet.jsp.JspException JavaDoc {
110       try {
111          Field field = getField();
112
113          /*
114                             <input type="hidden" name="searchalgo_0_1" value="weakEnd"/>
115                             <input type="hidden" name="searchmode_0_1" value="AND"/>
116                             <input type="input" name="search_0_1"/>
117          */

118          StringBuffer JavaDoc tagBuf = new StringBuffer JavaDoc();
119
120          StringBuffer JavaDoc paramNameBuf = new StringBuffer JavaDoc();
121          paramNameBuf.append(field.getSearchFieldName());
122
123          tagBuf.append("<input type=\"checkbox\" name=\"");
124          tagBuf.append(paramNameBuf.toString());
125          tagBuf.append("\" ");
126          tagBuf.append("value=\"");
127          tagBuf.append(getValue());
128
129          if (Util.getTrue(getChecked())) {
130             tagBuf.append(" checked=\"checked\" ");
131          }
132
133          tagBuf.append("\"");
134          tagBuf.append(prepareStyles());
135          tagBuf.append(prepareEventHandlers());
136          tagBuf.append("/>\n");
137
138          pageContext.getOut()
139                     .write(renderPatternHtmlInputField());
140          pageContext.getOut()
141                     .write(RenderHiddenFields(field));
142          pageContext.getOut()
143                     .write(tagBuf.toString());
144       } catch (java.io.IOException JavaDoc ioe) {
145          throw new JspException JavaDoc("IO Error: " + ioe.getMessage());
146       }
147
148       return EVAL_PAGE;
149    }
150
151
152    /**
153     * DOCUMENT ME!
154     */

155    public void doFinally() {
156       checked = "false";
157       value = null;
158       super.doFinally();
159    }
160 }
161
Popular Tags