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