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