1 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 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 58 public void setChecked(String string) { 59 checked = string; 60 } 61 62 63 68 public String getChecked() { 69 return checked; 70 } 71 72 73 78 public void setValue(String string) { 79 value = string; 80 } 81 82 83 88 public String getValue() { 89 return value; 90 } 91 92 93 96 public void doCatch(Throwable t) throws Throwable { 97 throw t; 98 } 99 100 101 109 public int doEndTag() throws javax.servlet.jsp.JspException { 110 try { 111 Field field = getField(); 112 113 118 StringBuffer tagBuf = new StringBuffer (); 119 120 StringBuffer paramNameBuf = new StringBuffer (); 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 ioe) { 145 throw new JspException ("IO Error: " + ioe.getMessage()); 146 } 147 148 return EVAL_PAGE; 149 } 150 151 152 155 public void doFinally() { 156 checked = "false"; 157 value = null; 158 super.doFinally(); 159 } 160 } 161 | Popular Tags |