001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019
020 package org.apache.myfaces.tobago.taglib.extension;
021
022 import org.apache.myfaces.tobago.apt.annotation.ExtensionTag;
023 import org.apache.myfaces.tobago.apt.annotation.Tag;
024 import org.apache.myfaces.tobago.taglib.component.TextAreaTag;
025 import org.apache.myfaces.tobago.taglib.decl.HasConverter;
026 import org.apache.myfaces.tobago.taglib.decl.HasIdBindingAndRendered;
027 import org.apache.myfaces.tobago.taglib.decl.HasLabel;
028 import org.apache.myfaces.tobago.taglib.decl.HasLabelWidth;
029 import org.apache.myfaces.tobago.taglib.decl.HasMarkup;
030 import org.apache.myfaces.tobago.taglib.decl.HasOnchange;
031 import org.apache.myfaces.tobago.taglib.decl.HasTabIndex;
032 import org.apache.myfaces.tobago.taglib.decl.HasTip;
033 import org.apache.myfaces.tobago.taglib.decl.HasValidator;
034 import org.apache.myfaces.tobago.taglib.decl.HasValue;
035 import org.apache.myfaces.tobago.taglib.decl.HasValueChangeListener;
036 import org.apache.myfaces.tobago.taglib.decl.IsDisabled;
037 import org.apache.myfaces.tobago.taglib.decl.IsFocus;
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 multiline text input control 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:textarea value="#{value}">
056 * ...
057 * </tc:in>
058 * </tc:panel>
059 * </pre>
060 */
061
062 @Tag(name = "textarea")
063 @ExtensionTag(baseClassName = "org.apache.myfaces.tobago.taglib.component.TextAreaTag")
064 public class TextAreaExtensionTag extends BodyTagSupport
065 implements HasValue, HasValueChangeListener, HasIdBindingAndRendered,
066 HasConverter, HasValidator, IsReadonly, IsDisabled, HasMarkup, IsRequired,
067 HasTip, HasLabel, HasLabelWidth, IsFocus, HasOnchange, HasTabIndex {
068
069 private String binding;
070 private String converter;
071 private String disabled;
072 private String focus;
073 private String label;
074 private String readonly;
075 private String rendered;
076 private String required;
077 private String tip;
078 private String value;
079 private String valueChangeListener;
080 private String validator;
081 private String onchange;
082 private String markup;
083 private String labelWidth;
084 private String tabIndex;
085
086 private LabelExtensionTag labelTag;
087 private TextAreaTag textAreaTag;
088
089 @Override
090 public int doStartTag() throws JspException {
091
092 labelTag = new LabelExtensionTag();
093 labelTag.setPageContext(pageContext);
094 labelTag.setRows("*");
095 if (label != null) {
096 labelTag.setValue(label);
097 }
098 if (tip != null) {
099 labelTag.setTip(tip);
100 }
101 if (rendered != null) {
102 labelTag.setRendered(rendered);
103 }
104 if (labelWidth != null) {
105 labelTag.setColumns(labelWidth + ";*");
106 }
107 if (markup != null) {
108 labelTag.setMarkup(markup);
109 }
110 labelTag.setParent(getParent());
111 labelTag.doStartTag();
112
113 textAreaTag = new TextAreaTag();
114 textAreaTag.setPageContext(pageContext);
115 if (value != null) {
116 textAreaTag.setValue(value);
117 }
118 if (valueChangeListener != null) {
119 textAreaTag.setValueChangeListener(valueChangeListener);
120 }
121 if (binding != null) {
122 textAreaTag.setBinding(binding);
123 }
124 if (converter != null) {
125 textAreaTag.setConverter(converter);
126 }
127 if (validator != null) {
128 textAreaTag.setValidator(validator);
129 }
130 if (onchange != null) {
131 textAreaTag.setOnchange(onchange);
132 }
133 if (disabled != null) {
134 textAreaTag.setDisabled(disabled);
135 }
136 if (focus != null) {
137 textAreaTag.setFocus(focus);
138 }
139 if (id != null) {
140 textAreaTag.setId(id);
141 }
142 if (readonly != null) {
143 textAreaTag.setReadonly(readonly);
144 }
145 if (required != null) {
146 textAreaTag.setRequired(required);
147 }
148 if (markup != null) {
149 textAreaTag.setMarkup(markup);
150 }
151 if (tabIndex != null) {
152 textAreaTag.setTabIndex(tabIndex);
153 }
154 textAreaTag.setParent(labelTag);
155 textAreaTag.doStartTag();
156
157 return super.doStartTag();
158 }
159
160 @Override
161 public int doEndTag() throws JspException {
162 textAreaTag.doEndTag();
163 labelTag.doEndTag();
164 return super.doEndTag();
165 }
166
167 @Override
168 public void release() {
169 super.release();
170 binding = null;
171 converter = null;
172 validator = null;
173 disabled = null;
174 labelWidth = null;
175 focus = null;
176 label = null;
177 readonly = null;
178 rendered = null;
179 required = null;
180 tip = null;
181 value = null;
182 onchange = null;
183 markup = null;
184 valueChangeListener = null;
185 tabIndex = null;
186 textAreaTag = null;
187 labelTag = null;
188 }
189
190 public void setValue(String value) {
191 this.value = value;
192 }
193
194 public void setValueChangeListener(String valueChangeListener) {
195 this.valueChangeListener = valueChangeListener;
196 }
197
198 public void setLabel(String label) {
199 this.label = label;
200 }
201
202 public void setFocus(String focus) {
203 this.focus = focus;
204 }
205
206 public void setBinding(String binding) {
207 this.binding = binding;
208 }
209
210 public void setRendered(String rendered) {
211 this.rendered = rendered;
212 }
213
214 public void setConverter(String converter) {
215 this.converter = converter;
216 }
217
218 public void setValidator(String validator) {
219 this.validator = validator;
220 }
221
222 public void setOnchange(String onchange) {
223 this.onchange = onchange;
224 }
225
226 public void setMarkup(String markup) {
227 this.markup = markup;
228 }
229
230 public void setReadonly(String readonly) {
231 this.readonly = readonly;
232 }
233
234 public void setDisabled(String disabled) {
235 this.disabled = disabled;
236 }
237
238 public void setRequired(String required) {
239 this.required = required;
240 }
241
242 public void setTip(String tip) {
243 this.tip = tip;
244 }
245
246 public void setLabelWidth(String labelWidth) {
247 this.labelWidth = labelWidth;
248 }
249
250 public void setTabIndex(String tabIndex) {
251 this.tabIndex = tabIndex;
252 }
253 }