001 package org.apache.myfaces.tobago.taglib.extension; 002 003 /* 004 * Licensed to the Apache Software Foundation (ASF) under one or more 005 * contributor license agreements. See the NOTICE file distributed with 006 * this work for additional information regarding copyright ownership. 007 * The ASF licenses this file to You under the Apache License, Version 2.0 008 * (the "License"); you may not use this file except in compliance with 009 * the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 */ 019 020 import org.apache.myfaces.tobago.apt.annotation.ExtensionTag; 021 import org.apache.myfaces.tobago.apt.annotation.Tag; 022 import org.apache.myfaces.tobago.taglib.component.SelectBooleanCheckboxTag; 023 import org.apache.myfaces.tobago.taglib.component.TobagoTagDeclaration; 024 import org.apache.myfaces.tobago.taglib.decl.HasBooleanValue; 025 import org.apache.myfaces.tobago.taglib.decl.HasIdBindingAndRendered; 026 import org.apache.myfaces.tobago.taglib.decl.HasLabel; 027 import org.apache.myfaces.tobago.taglib.decl.HasLabelWidth; 028 import org.apache.myfaces.tobago.taglib.decl.HasMarkup; 029 import org.apache.myfaces.tobago.taglib.decl.HasOnchange; 030 import org.apache.myfaces.tobago.taglib.decl.HasTabIndex; 031 import org.apache.myfaces.tobago.taglib.decl.HasTip; 032 import org.apache.myfaces.tobago.taglib.decl.HasValidator; 033 import org.apache.myfaces.tobago.taglib.decl.HasValueChangeListener; 034 import org.apache.myfaces.tobago.taglib.decl.IsDisabled; 035 import org.apache.myfaces.tobago.taglib.decl.IsReadonly; 036 //import org.apache.myfaces.tobago.taglib.decl.IsRequired; 037 import org.apache.myfaces.tobago.taglib.decl.IsFocus; 038 039 import javax.servlet.jsp.JspException; 040 import javax.servlet.jsp.tagext.BodyTagSupport; 041 042 /* 043 * Date: Oct 7, 2006 044 * Time: 9:13:21 AM 045 */ 046 /** 047 * Renders a checkbox. 048 */ 049 @Tag(name = "selectBooleanCheckbox") 050 @ExtensionTag(baseClassName = "org.apache.myfaces.tobago.taglib.component.SelectBooleanCheckboxTag") 051 public class SelectBooleanCheckboxExtensionTag extends BodyTagSupport implements TobagoTagDeclaration, 052 HasValidator, HasOnchange, HasValueChangeListener, HasIdBindingAndRendered, HasLabel, 053 HasBooleanValue, HasLabelWidth, IsDisabled, HasTip, IsReadonly, HasMarkup, HasTabIndex, //IsRequired 054 IsFocus { 055 056 private String value; 057 private String valueChangeListener; 058 private String disabled; 059 private String readonly; 060 private String onchange; 061 private String label; 062 private String rendered; 063 private String binding; 064 private String tip; 065 private String converter; 066 private String validator; 067 private String labelWidth; 068 private String markup; 069 private String tabIndex; 070 //private String required; 071 private String focus; 072 073 private LabelExtensionTag labelTag; 074 private SelectBooleanCheckboxTag selectBooleanCheckboxTag; 075 076 @Override 077 public int doStartTag() throws JspException { 078 079 labelTag = new LabelExtensionTag(); 080 labelTag.setPageContext(pageContext); 081 if (label != null) { 082 labelTag.setValue(label); 083 } 084 if (tip != null) { 085 labelTag.setTip(tip); 086 } 087 if (rendered != null) { 088 labelTag.setRendered(rendered); 089 } 090 if (labelWidth != null) { 091 labelTag.setColumns(labelWidth + ";*"); 092 } 093 /* TODO accessKey 094 if (labelWithAccessKey != null) { 095 label.setLabelWithAccessKey(labelWithAccessKey); 096 } 097 if (accessKey !=null) { 098 label.setAccessKey(accessKey); 099 } */ 100 labelTag.setParent(getParent()); 101 labelTag.doStartTag(); 102 103 selectBooleanCheckboxTag = new SelectBooleanCheckboxTag(); 104 selectBooleanCheckboxTag.setPageContext(pageContext); 105 if (value != null) { 106 selectBooleanCheckboxTag.setValue(value); 107 } 108 if (valueChangeListener != null) { 109 selectBooleanCheckboxTag.setValueChangeListener(valueChangeListener); 110 } 111 if (binding != null) { 112 selectBooleanCheckboxTag.setBinding(binding); 113 } 114 if (onchange != null) { 115 selectBooleanCheckboxTag.setOnchange(onchange); 116 } 117 if (validator != null) { 118 selectBooleanCheckboxTag.setValidator(validator); 119 } 120 if (converter != null) { 121 selectBooleanCheckboxTag.setConverter(converter); 122 } 123 if (disabled != null) { 124 selectBooleanCheckboxTag.setDisabled(disabled); 125 } 126 127 if (id != null) { 128 selectBooleanCheckboxTag.setId(id); 129 } 130 131 if (readonly != null) { 132 selectBooleanCheckboxTag.setReadonly(readonly); 133 } 134 135 if (focus != null) { 136 selectBooleanCheckboxTag.setFocus(focus); 137 } 138 139 //if (required != null) { 140 // selectBooleanCheckboxTag.setRequired(required); 141 //} 142 // TODO item Label 143 //if (itemLabel != null) { 144 // selectOneRadioTag.setLabel(itemLabel); 145 //} 146 147 if (markup != null) { 148 selectBooleanCheckboxTag.setMarkup(markup); 149 } 150 if (tabIndex != null) { 151 selectBooleanCheckboxTag.setTabIndex(tabIndex); 152 } 153 selectBooleanCheckboxTag.setParent(labelTag); 154 selectBooleanCheckboxTag.doStartTag(); 155 156 return super.doStartTag(); 157 } 158 159 @Override 160 public int doEndTag() throws JspException { 161 selectBooleanCheckboxTag.doEndTag(); 162 labelTag.doEndTag(); 163 return super.doEndTag(); 164 } 165 166 @Override 167 public void release() { 168 super.release(); 169 binding = null; 170 onchange = null; 171 disabled = null; 172 label = null; 173 labelWidth = null; 174 readonly = null; 175 rendered = null; 176 converter = null; 177 validator = null; 178 tip = null; 179 value = null; 180 valueChangeListener = null; 181 markup = null; 182 tabIndex = null; 183 focus = null; 184 //required = null; 185 selectBooleanCheckboxTag = null; 186 labelTag = null; 187 } 188 189 public void setValue(String value) { 190 this.value = value; 191 } 192 193 public void setValueChangeListener(String valueChangeListener) { 194 this.valueChangeListener = valueChangeListener; 195 } 196 197 public void setDisabled(String disabled) { 198 this.disabled = disabled; 199 } 200 201 public void setReadonly(String readonly) { 202 this.readonly = readonly; 203 } 204 205 public void setOnchange(String onchange) { 206 this.onchange = onchange; 207 } 208 209 public void setLabel(String label) { 210 this.label = label; 211 } 212 213 public void setValidator(String validator) { 214 this.validator = validator; 215 } 216 217 public void setConverter(String converter) { 218 this.converter = converter; 219 } 220 221 public void setRendered(String rendered) { 222 this.rendered = rendered; 223 } 224 225 public void setBinding(String binding) { 226 this.binding = binding; 227 } 228 229 public void setTip(String tip) { 230 this.tip = tip; 231 } 232 233 public void setLabelWidth(String labelWidth) { 234 this.labelWidth = labelWidth; 235 } 236 237 public void setMarkup(String markup) { 238 this.markup = markup; 239 } 240 241 public void setTabIndex(String tabIndex) { 242 this.tabIndex = tabIndex; 243 } 244 245 public void setFocus(String focus) { 246 this.focus = focus; 247 } 248 249 //public void setRequired(String required) { 250 // this.required = required; 251 //} 252 }