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