001// Licensed under the Apache License, Version 2.0 (the "License"); 002// you may not use this file except in compliance with the License. 003// You may obtain a copy of the License at 004// 005// http://www.apache.org/licenses/LICENSE-2.0 006// 007// Unless required by applicable law or agreed to in writing, software 008// distributed under the License is distributed on an "AS IS" BASIS, 009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 010// See the License for the specific language governing permissions and 011// limitations under the License. 012 013package org.apache.tapestry5.corelib.components; 014 015import org.apache.tapestry5.MarkupWriter; 016import org.apache.tapestry5.corelib.base.AbstractTextField; 017 018/** 019 * TextArea component corresponds to a <textarea> element. The value parameter is almost always bound to a string, 020 * but this is not an absolute requirement. Since the component accepts informal parameters, the rows and cols attribute may 021 * be set that way (there is not a formal parameter). 022 * 023 * Includes the <code>cols</code> attribute, if a {@link org.apache.tapestry5.beaneditor.Width} annotation is present on 024 * the property bound to the value parameter. 025 * 026 * @tapestrydoc 027 * @see org.apache.tapestry5.corelib.components.TextOutput 028 * @see TextField 029 * @see Form 030 */ 031public class TextArea extends AbstractTextField 032{ 033 private String value; 034 035 @Override 036 protected final void writeFieldTag(MarkupWriter writer, String value) 037 { 038 writer.element("textarea", 039 040 "name", getControlName(), 041 042 "class", cssClass, 043 044 "id", getClientId(), 045 046 "cols", getWidth()); 047 048 // Save until needed in after() 049 050 this.value = value; 051 } 052 053 final void afterRender(MarkupWriter writer) 054 { 055 // TextArea will not have a template. 056 057 if (value != null) 058 writer.write(value); 059 060 writer.end(); // textarea 061 } 062 063}