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.Tag; 021 import org.apache.myfaces.tobago.apt.annotation.ExtensionTag; 022 import org.apache.myfaces.tobago.taglib.decl.HasLabel; 023 import org.apache.myfaces.tobago.taglib.decl.HasOnchange; 024 import org.apache.myfaces.tobago.taglib.decl.HasBooleanValue; 025 import org.apache.myfaces.tobago.taglib.decl.HasValueChangeListener; 026 import org.apache.myfaces.tobago.taglib.decl.IsDisabled; 027 import org.apache.myfaces.tobago.taglib.decl.HasIdBindingAndRendered; 028 import org.apache.myfaces.tobago.taglib.decl.HasTip; 029 import org.apache.myfaces.tobago.taglib.decl.HasValidator; 030 import org.apache.myfaces.tobago.taglib.decl.IsReadonly; 031 import org.apache.myfaces.tobago.taglib.decl.HasLabelWidth; 032 import org.apache.myfaces.tobago.taglib.decl.HasMarkup; 033 import org.apache.myfaces.tobago.taglib.component.SelectBooleanCheckboxTag; 034 import org.apache.myfaces.tobago.taglib.component.TobagoTagDeclaration; 035 036 import javax.servlet.jsp.JspException; 037 import javax.servlet.jsp.tagext.BodyTagSupport; 038 039 /* 040 * Created by IntelliJ IDEA. 041 * User: bommel 042 * Date: Oct 7, 2006 043 * Time: 9:13:21 AM 044 */ 045 /** 046 * Renders a checkbox. 047 */ 048 @Tag(name = "selectBooleanCheckbox") 049 @ExtensionTag(baseClassName = "org.apache.myfaces.tobago.taglib.component.SelectBooleanCheckboxTag") 050 public class SelectBooleanCheckboxExtensionTag extends BodyTagSupport implements TobagoTagDeclaration, 051 HasValidator, HasOnchange, HasValueChangeListener, HasIdBindingAndRendered, HasLabel, 052 HasBooleanValue, HasLabelWidth, IsDisabled, HasTip, IsReadonly, HasMarkup { 053 054 private String value; 055 private String valueChangeListener; 056 private String disabled; 057 private String readonly; 058 private String onchange; 059 private String label; 060 private String rendered; 061 private String binding; 062 private String tip; 063 private String converter; 064 private String validator; 065 private String labelWidth; 066 private String markup; 067 068 private LabelExtensionTag labelTag; 069 private SelectBooleanCheckboxTag selectBooleanCheckboxTag; 070 071 @Override 072 public int doStartTag() throws JspException { 073 074 labelTag = new LabelExtensionTag(); 075 labelTag.setPageContext(pageContext); 076 if (label != null) { 077 labelTag.setValue(label); 078 } 079 if (tip != null) { 080 labelTag.setTip(tip); 081 } 082 if (rendered != null) { 083 labelTag.setRendered(rendered); 084 } 085 if (labelWidth != null) { 086 labelTag.setColumns(labelWidth + ";*"); 087 } 088 /* TODO accessKey 089 if (labelWithAccessKey != null) { 090 label.setLabelWithAccessKey(labelWithAccessKey); 091 } 092 if (accessKey !=null) { 093 label.setAccessKey(accessKey); 094 } */ 095 labelTag.setParent(getParent()); 096 labelTag.doStartTag(); 097 098 selectBooleanCheckboxTag = new SelectBooleanCheckboxTag(); 099 selectBooleanCheckboxTag.setPageContext(pageContext); 100 if (value != null) { 101 selectBooleanCheckboxTag.setValue(value); 102 } 103 if (valueChangeListener != null) { 104 selectBooleanCheckboxTag.setValueChangeListener(valueChangeListener); 105 } 106 if (binding != null) { 107 selectBooleanCheckboxTag.setBinding(binding); 108 } 109 if (onchange != null) { 110 selectBooleanCheckboxTag.setOnchange(onchange); 111 } 112 if (validator != null) { 113 selectBooleanCheckboxTag.setValidator(validator); 114 } 115 if (converter != null) { 116 selectBooleanCheckboxTag.setConverter(converter); 117 } 118 if (disabled != null) { 119 selectBooleanCheckboxTag.setDisabled(disabled); 120 } 121 122 if (id != null) { 123 selectBooleanCheckboxTag.setId(id); 124 } 125 126 if (readonly != null) { 127 selectBooleanCheckboxTag.setReadonly(readonly); 128 } 129 130 //if (required != null) { 131 // selectBooleanCheckboxTag.setRequired(required); 132 //} 133 134 if (markup != null) { 135 selectBooleanCheckboxTag.setMarkup(markup); 136 } 137 selectBooleanCheckboxTag.setParent(labelTag); 138 selectBooleanCheckboxTag.doStartTag(); 139 140 return super.doStartTag(); 141 } 142 143 @Override 144 public int doEndTag() throws JspException { 145 selectBooleanCheckboxTag.doEndTag(); 146 labelTag.doEndTag(); 147 return super.doEndTag(); 148 } 149 150 @Override 151 public void release() { 152 super.release(); 153 binding = null; 154 onchange = null; 155 disabled = null; 156 label = null; 157 labelWidth = null; 158 readonly = null; 159 rendered = null; 160 converter = null; 161 validator = null; 162 tip = null; 163 value = null; 164 valueChangeListener = null; 165 markup = null; 166 } 167 168 public void setValue(String value) { 169 this.value = value; 170 } 171 172 public void setValueChangeListener(String valueChangeListener) { 173 this.valueChangeListener = valueChangeListener; 174 } 175 176 public void setDisabled(String disabled) { 177 this.disabled = disabled; 178 } 179 180 public void setReadonly(String readonly) { 181 this.readonly = readonly; 182 } 183 184 public void setOnchange(String onchange) { 185 this.onchange = onchange; 186 } 187 188 public void setLabel(String label) { 189 this.label = label; 190 } 191 192 193 public void setValidator(String validator) { 194 this.validator = validator; 195 } 196 197 public void setConverter(String converter) { 198 this.converter = converter; 199 } 200 201 public void setRendered(String rendered) { 202 this.rendered = rendered; 203 } 204 205 public void setBinding(String binding) { 206 this.binding = binding; 207 } 208 209 public void setTip(String tip) { 210 this.tip = tip; 211 } 212 213 public void setLabelWidth(String labelWidth) { 214 this.labelWidth = labelWidth; 215 } 216 217 public void setMarkup(String markup) { 218 this.markup = markup; 219 } 220 221 }