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 109 labelTag.setParent(getParent()); 110 labelTag.doStartTag(); 111 112 inTag = new InTag(); 113 inTag.setPageContext(pageContext); 114 if (value != null) { 115 inTag.setValue(value); 116 } 117 if (valueChangeListener != null) { 118 inTag.setValueChangeListener(valueChangeListener); 119 } 120 if (binding != null) { 121 inTag.setBinding(binding); 122 } 123 if (converter != null) { 124 inTag.setConverter(converter); 125 } 126 if (validator != null) { 127 inTag.setValidator(validator); 128 } 129 if (onchange != null) { 130 inTag.setOnchange(onchange); 131 } 132 if (suggestMethod != null) { 133 inTag.setSuggestMethod(suggestMethod); 134 } 135 if (disabled != null) { 136 inTag.setDisabled(disabled); 137 } 138 if (focus != null) { 139 inTag.setFocus(focus); 140 } 141 if (id != null) { 142 inTag.setId(id); 143 } 144 if (password != null) { 145 inTag.setPassword(password); 146 } 147 if (readonly != null) { 148 inTag.setReadonly(readonly); 149 } 150 if (required != null) { 151 inTag.setRequired(required); 152 } 153 if (markup != null) { 154 inTag.setMarkup(markup); 155 } 156 if (tabIndex != null) { 157 inTag.setTabIndex(tabIndex); 158 } 159 inTag.setParent(labelTag); 160 inTag.doStartTag(); 161 162 return super.doStartTag(); 163 } 164 165 @Override 166 public int doEndTag() throws JspException { 167 inTag.doEndTag(); 168 labelTag.doEndTag(); 169 return super.doEndTag(); 170 } 171 172 @Override 173 public void release() { 174 super.release(); 175 binding = null; 176 converter = null; 177 validator = null; 178 disabled = null; 179 labelWidth = null; 180 focus = null; 181 label = null; 182 password = null; 183 readonly = null; 184 rendered = null; 185 required = null; 186 tip = null; 187 value = null; 188 valueChangeListener = null; 189 onchange = null; 190 suggestMethod = null; 191 markup = null; 192 tabIndex = null; 193 inTag = null; 194 labelTag = null; 195 } 196 197 public void setMarkup(String markup) { 198 this.markup = markup; 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 setLabel(String label) { 210 this.label = label; 211 } 212 213 public void setFocus(String focus) { 214 this.focus = focus; 215 } 216 217 public void setBinding(String binding) { 218 this.binding = binding; 219 } 220 221 public void setRendered(String rendered) { 222 this.rendered = rendered; 223 } 224 225 public void setConverter(String converter) { 226 this.converter = converter; 227 } 228 229 public void setOnchange(String onchange) { 230 this.onchange = onchange; 231 } 232 233 public void setSuggestMethod(String suggestMethod) { 234 this.suggestMethod = suggestMethod; 235 } 236 237 public void setValidator(String validator) { 238 this.validator = validator; 239 } 240 241 public void setPassword(String password) { 242 this.password = password; 243 } 244 245 public void setReadonly(String readonly) { 246 this.readonly = readonly; 247 } 248 249 public void setDisabled(String disabled) { 250 this.disabled = disabled; 251 } 252 253 public void setRequired(String required) { 254 this.required = required; 255 } 256 257 public void setTip(String tip) { 258 this.tip = tip; 259 } 260 261 public void setLabelWidth(String labelWidth) { 262 this.labelWidth = labelWidth; 263 } 264 265 public void setTabIndex(String tabIndex) { 266 this.tabIndex = tabIndex; 267 } 268 }