com.raj.htmlForms
Class HtmlTextArea

java.lang.Object
  |
  +--com.raj.htmlForms.HtmlFormElement
        |
        +--com.raj.htmlForms.HtmlTextArea

public class HtmlTextArea
extends HtmlFormElement

This class represents the <textarea> tag of a form. It will display a multi-line text box ready for typing in, optionally populated from a String or a Reader. Note: these two display methods are mutually exclusive -- you cannot use both a String and a reader simultaneously.

This class (HtmlTextArea.java) is part of the com.raj.htmlForms package that automatically generates HTML forms programmatically.

CREATED 26-FEB-2002, Copyright (c) Rajnish Bhaskar 2002

Author:
Rajnish Bhaskar
See Also:
W3C Reference of the select attribute

Field Summary
 
Fields inherited from class com.raj.htmlForms.HtmlFormElement
isXHTML, out
 
Constructor Summary
HtmlTextArea(java.io.Writer w)
          Minimal constructor for any form element.
HtmlTextArea(java.io.Writer w, boolean x)
          Constructor that sets the writer and a boolean which determines whether or not XHTML will be written
HtmlTextArea(java.io.Writer w, java.lang.String n)
          Constructor that just sets the name of the element
HtmlTextArea(java.io.Writer w, java.lang.String n, int row, int col)
          Constructor that just sets the name of the element
HtmlTextArea(java.io.Writer w, java.lang.String n, java.io.Reader r, int row, int col)
          Constructor that sets the name of the element and populates it from a Reader object
HtmlTextArea(java.io.Writer w, java.lang.String n, java.lang.String t, int row, int col)
          Constructor that sets the name of the element and populates it from a String
 
Method Summary
 java.lang.String getCols()
          gets the number of cols for this textarea
 java.io.Reader getReader()
          returns the reader being used to populate this textarea (or null if a string is being used)
 java.lang.String getRows()
          gets the number of rows for this textarea
 java.lang.String getText()
          return the String from which the textarea will be populated
 void reset()
          resets all attributes of the element back to a blank state
 void setCols(int x)
          sets the number of cols for this textarea
 void setReader(java.io.Reader r)
          This is an alternative way of populating a textarea.
 void setRows(int x)
          sets the number of rows for this textarea
 void setText(java.lang.String x)
          set the text that you want to use to populate the textarea with
 java.lang.String toString()
          Writes the attributes of this object to a string and returns them.
 void write()
          writes an HTML textarea to the given writer
 
Methods inherited from class com.raj.htmlForms.HtmlFormElement
getDir, getId, getLang, getName, getOnBlur, getOnClick, getOnDblClick, getOnFocus, getOnKeyDown, getOnKeyPress, getOnKeyUp, getOnMouseDown, getOnMouseMove, getOnMouseOut, getOnMouseOver, getOnMouseUp, getOnSelect, getStyle, getTabIndex, getTheClass, getTitle, getXhtml, setDir, setId, setLang, setName, setOnBlur, setOnClick, setOnDblClick, setOnFocus, setOnKeyDown, setOnKeyPress, setOnKeyUp, setOnMouseDown, setOnMouseMove, setOnMouseOut, setOnMouseOver, setOnMouseUp, setOnSelect, setStyle, setStyle, setTabIndex, setTheClass, setTitle, setXhtml
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HtmlTextArea

public HtmlTextArea(java.io.Writer w)
Minimal constructor for any form element. All other attributes can be added by the appropriate setter method. This follows the standard Java convention for attributes, so the attribute foo becomes setFoo(). The attribute names can be found at the W3C HTML reference or many other places on the web.

Parameters:
w - the Writer to which all the data will be written out
See Also:
W3C Reference for forms

HtmlTextArea

public HtmlTextArea(java.io.Writer w,
                    boolean x)
Constructor that sets the writer and a boolean which determines whether or not XHTML will be written

Parameters:
w - the Writer to which all the data will be written out
x - if true, XHTML will be written, else false

HtmlTextArea

public HtmlTextArea(java.io.Writer w,
                    java.lang.String n)
Constructor that just sets the name of the element

Parameters:
w - the Writer to which all the data will be written out
n - the name of this element
See Also:
W3C Reference for forms

HtmlTextArea

public HtmlTextArea(java.io.Writer w,
                    java.lang.String n,
                    int row,
                    int col)
Constructor that just sets the name of the element

Parameters:
w - the Writer to which all the data will be written out
n - the name of this element
row - the number of rows
col - the number of cols
See Also:
W3C Reference for forms

HtmlTextArea

public HtmlTextArea(java.io.Writer w,
                    java.lang.String n,
                    java.lang.String t,
                    int row,
                    int col)
Constructor that sets the name of the element and populates it from a String

Parameters:
w - the Writer to which all the data will be written out
n - the name of this element
t - the String from which the textarea will be populated
row - the number of rows
col - the number of cols
See Also:
W3C Reference for forms

HtmlTextArea

public HtmlTextArea(java.io.Writer w,
                    java.lang.String n,
                    java.io.Reader r,
                    int row,
                    int col)
Constructor that sets the name of the element and populates it from a Reader object

Parameters:
w - the Writer to which all the data will be written out
n - the name of this element
r - the Reader which will be used to populate this element
row - the number of rows
col - the number of cols
See Also:
W3C Reference for forms
Method Detail

setRows

public void setRows(int x)
sets the number of rows for this textarea

See Also:
W3C reference of this attribute

getRows

public java.lang.String getRows()
gets the number of rows for this textarea

See Also:
W3C reference of this attribute

setCols

public void setCols(int x)
sets the number of cols for this textarea

See Also:
W3C reference of this attribute

getCols

public java.lang.String getCols()
gets the number of cols for this textarea

See Also:
W3C reference of this attribute

setText

public void setText(java.lang.String x)
set the text that you want to use to populate the textarea with


getText

public java.lang.String getText()
return the String from which the textarea will be populated


setReader

public void setReader(java.io.Reader r)
This is an alternative way of populating a textarea. The reader can read from a file, string or network connection (by wrapping the InputStream returned from a URL object in the constructor of an InputStreamReader)


getReader

public java.io.Reader getReader()
returns the reader being used to populate this textarea (or null if a string is being used)


reset

public void reset()
Description copied from class: HtmlFormElement
resets all attributes of the element back to a blank state

Overrides:
reset in class HtmlFormElement

toString

public java.lang.String toString()
Description copied from class: HtmlFormElement
Writes the attributes of this object to a string and returns them.

The toString() method should logically return a string representing the attributes of the HTML element, eg if you set the name, title and style of the element then you should return a string containing:

name="myName" title="some title" style="foo: xxx; bar: yyy;"

The responsibility for turning this into a form deliverable to a user agent belongs to the write() method.

Overrides:
toString in class HtmlFormElement
See Also:
HtmlFormElement.write()

write

public void write()
writes an HTML textarea to the given writer

Specified by:
write in class HtmlFormElement