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.taglib.decl.HasId; 021 import org.apache.myfaces.tobago.taglib.decl.HasValue; 022 import org.apache.myfaces.tobago.taglib.decl.HasValueChangeListener; 023 import org.apache.myfaces.tobago.taglib.decl.IsDisabled; 024 import org.apache.myfaces.tobago.taglib.decl.HasDeprecatedHeight; 025 import org.apache.myfaces.tobago.taglib.decl.IsInline; 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.IsRendered; 029 import org.apache.myfaces.tobago.taglib.decl.HasBinding; 030 import org.apache.myfaces.tobago.taglib.decl.HasTip; 031 import org.apache.myfaces.tobago.taglib.decl.HasConverter; 032 import org.apache.myfaces.tobago.taglib.decl.HasValidator; 033 import org.apache.myfaces.tobago.taglib.decl.HasOnchange; 034 import org.apache.myfaces.tobago.taglib.decl.IsReadonly; 035 import org.apache.myfaces.tobago.taglib.decl.HasMarkup; 036 import org.apache.myfaces.tobago.taglib.decl.IsFocus; 037 import org.apache.myfaces.tobago.taglib.decl.IsRequired; 038 import org.apache.myfaces.tobago.taglib.decl.HasTabIndex; 039 import org.apache.myfaces.tobago.taglib.decl.HasRenderRange; 040 import org.apache.myfaces.tobago.taglib.component.SelectManyCheckboxTag; 041 import org.apache.myfaces.tobago.apt.annotation.Tag; 042 import org.apache.myfaces.tobago.apt.annotation.ExtensionTag; 043 044 import javax.servlet.jsp.tagext.BodyTagSupport; 045 import javax.servlet.jsp.JspException; 046 047 /** 048 * Render a group of checkboxes. 049 */ 050 @Tag(name = "selectManyCheckbox") 051 @ExtensionTag(baseClassName = "org.apache.myfaces.tobago.taglib.component.SelectManyCheckboxTag") 052 public class SelectManyCheckboxExtensionTag extends BodyTagSupport 053 implements HasId, HasValue, HasValueChangeListener, IsDisabled, HasDeprecatedHeight, IsInline, 054 HasLabel, HasLabelWidth, IsRendered, HasBinding, HasTip, HasConverter, HasValidator, HasOnchange, 055 IsReadonly, HasMarkup, IsFocus, IsRequired, HasTabIndex, HasRenderRange { 056 057 private String required; 058 private String value; 059 private String valueChangeListener; 060 private String disabled; 061 private String readonly; 062 private String onchange; 063 private String inline; 064 private String label; 065 private String rendered; 066 private String binding; 067 private String tip; 068 private String height; 069 private String converter; 070 private String validator; 071 private String labelWidth; 072 private String markup; 073 private String tabIndex; 074 private String focus; 075 private String renderRange; 076 077 private LabelExtensionTag labelTag; 078 private SelectManyCheckboxTag selectManyCheckboxTag; 079 080 @Override 081 public int doStartTag() throws JspException { 082 083 labelTag = new LabelExtensionTag(); 084 labelTag.setPageContext(pageContext); 085 labelTag.setRows("*"); 086 if (label != null) { 087 labelTag.setValue(label); 088 } 089 if (tip != null) { 090 labelTag.setTip(tip); 091 } 092 if (rendered != null) { 093 labelTag.setRendered(rendered); 094 } 095 if (labelWidth != null) { 096 labelTag.setColumns(labelWidth + ";*"); 097 } 098 /* TODO accessKey 099 if (labelWithAccessKey != null) { 100 label.setLabelWithAccessKey(labelWithAccessKey); 101 } 102 if (accessKey !=null) { 103 label.setAccessKey(accessKey); 104 } */ 105 labelTag.setParent(getParent()); 106 labelTag.doStartTag(); 107 108 selectManyCheckboxTag = new SelectManyCheckboxTag(); 109 selectManyCheckboxTag.setPageContext(pageContext); 110 if (value != null) { 111 selectManyCheckboxTag.setValue(value); 112 } 113 if (valueChangeListener != null) { 114 selectManyCheckboxTag.setValueChangeListener(valueChangeListener); 115 } 116 if (binding != null) { 117 selectManyCheckboxTag.setBinding(binding); 118 } 119 if (onchange != null) { 120 selectManyCheckboxTag.setOnchange(onchange); 121 } 122 if (validator != null) { 123 selectManyCheckboxTag.setValidator(validator); 124 } 125 if (converter != null) { 126 selectManyCheckboxTag.setConverter(converter); 127 } 128 if (disabled != null) { 129 selectManyCheckboxTag.setDisabled(disabled); 130 } 131 if (inline != null) { 132 selectManyCheckboxTag.setInline(inline); 133 } 134 if (focus != null) { 135 selectManyCheckboxTag.setFocus(focus); 136 } 137 if (id != null) { 138 selectManyCheckboxTag.setId(id); 139 } 140 if (height != null) { 141 selectManyCheckboxTag.setHeight(height); 142 } 143 if (readonly != null) { 144 selectManyCheckboxTag.setReadonly(readonly); 145 } 146 if (required != null) { 147 selectManyCheckboxTag.setRequired(required); 148 } 149 if (markup != null) { 150 selectManyCheckboxTag.setMarkup(markup); 151 } 152 if (renderRange != null) { 153 selectManyCheckboxTag.setRenderRange(renderRange); 154 } 155 if (tabIndex != null) { 156 selectManyCheckboxTag.setTabIndex(tabIndex); 157 } 158 selectManyCheckboxTag.setParent(labelTag); 159 selectManyCheckboxTag.doStartTag(); 160 161 return super.doStartTag(); 162 } 163 164 @Override 165 public int doEndTag() throws JspException { 166 selectManyCheckboxTag.doEndTag(); 167 labelTag.doEndTag(); 168 return super.doEndTag(); 169 } 170 171 @Override 172 public void release() { 173 super.release(); 174 binding = null; 175 onchange = null; 176 disabled = null; 177 inline = null; 178 label = null; 179 labelWidth = null; 180 height = null; 181 readonly = null; 182 rendered = null; 183 converter = null; 184 validator = null; 185 required = null; 186 tip = null; 187 value = null; 188 valueChangeListener = null; 189 markup = null; 190 tabIndex = null; 191 selectManyCheckboxTag = null; 192 labelTag = null; 193 focus = null; 194 renderRange = null; 195 } 196 197 public void setRequired(String required) { 198 this.required = required; 199 } 200 201 public void setValue(String value) { 202 this.value = value; 203 } 204 205 public void setValueChangeListener(String valueChangeListener) { 206 this.valueChangeListener = valueChangeListener; 207 } 208 209 public void setDisabled(String disabled) { 210 this.disabled = disabled; 211 } 212 213 public void setReadonly(String readonly) { 214 this.readonly = readonly; 215 } 216 217 public void setOnchange(String onchange) { 218 this.onchange = onchange; 219 } 220 221 public void setInline(String inline) { 222 this.inline = inline; 223 } 224 225 public void setLabel(String label) { 226 this.label = label; 227 } 228 229 public void setHeight(String height) { 230 this.height = height; 231 } 232 233 public void setValidator(String validator) { 234 this.validator = validator; 235 } 236 237 public void setConverter(String converter) { 238 this.converter = converter; 239 } 240 241 public void setRendered(String rendered) { 242 this.rendered = rendered; 243 } 244 245 public void setBinding(String binding) { 246 this.binding = binding; 247 } 248 249 public void setTip(String tip) { 250 this.tip = tip; 251 } 252 253 public void setLabelWidth(String labelWidth) { 254 this.labelWidth = labelWidth; 255 } 256 257 public void setMarkup(String markup) { 258 this.markup = markup; 259 } 260 261 public void setTabIndex(String tabIndex) { 262 this.tabIndex = tabIndex; 263 } 264 265 public void setFocus(String focus) { 266 this.focus = focus; 267 } 268 269 public void setRenderRange(String renderRange) { 270 this.renderRange = renderRange; 271 } 272 } 273