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