123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
package net.sf.tapestry.form; import net.sf.tapestry.IBinding; import net.sf.tapestry.IForm; import net.sf.tapestry.IMarkupWriter; import net.sf.tapestry.IRequestCycle; import net.sf.tapestry.RequestCycleException; import net.sf.tapestry.RequiredParameterException; import net.sf.tapestry.Tapestry; /** * Implements a component that manages an HTML <textarea> form element. * * [<a href="../../../../../ComponentReference/TextArea.html">Component Reference</a>] * * * @author Howard Lewis Ship * @version $Id: TextArea.java,v 1.4 2002/11/27 17:58:47 hship Exp $ * **/ public class TextArea extends AbstractFormComponent { private int _rows; private int _columns; private boolean _disabled; private String _name; public String getName() { return _name; } /** @since 2.2 **/ private String _value; /** * Renders the form element, or responds when the form containing the element * is submitted (by checking {@link Form#isRewinding()}. * **/ protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) throws RequestCycleException { IForm form = getForm(cycle); // It isn't enough to know whether the cycle in general is rewinding, need to know // specifically if the form which contains this component is rewinding. boolean rewinding = form.isRewinding(); // Used whether rewinding or not. _name = form.getElementId(this); if (rewinding) { _value = cycle.getRequestContext().getParameter(_name); return; } writer.begin("textarea"); writer.attribute("name", _name); if (_disabled) writer.attribute("disabled"); if (_rows != 0) writer.attribute("rows", _rows); if (_columns != 0) writer.attribute("cols", _columns); generateAttributes(writer, cycle); if (_value != null) writer.print(_value); writer.end(); } public int getColumns() { return _columns; } public void setColumns(int columns) { _columns = columns; } public boolean isDisabled() { return _disabled; } public void setDisabled(boolean disabled) { _disabled = disabled; } public int getRows() { return _rows; } public void setRows(int rows) { _rows = rows; } /** @since 2.2 **/ public String getValue() { return _value; } /** @since 2.2 **/ public void setValue(String value) { _value = value; } }