com.raj.htmlForms
Class HtmlFormElement

java.lang.Object
  |
  +--com.raj.htmlForms.HtmlFormElement
Direct Known Subclasses:
HtmlInput, HtmlSelect, HtmlTextArea

public abstract class HtmlFormElement
extends java.lang.Object

This class will be the superclass of other form elements. It will hold attributes and methods that are common to all elements. This includes both <input> and <select> tags but excludes any attributes that are unique to a particular tag.

HtmlForms is capable of writing either HTML 4.01 Transitional or XHTML 1.0 Transitional. If you want to write to the strict versions of these DTDs, omit any attributes that do not exist in that DTD.

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

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

Author:
Rajnish Bhaskar

Field Summary
protected  boolean isXHTML
           
protected  java.io.PrintWriter out
           
 
Constructor Summary
HtmlFormElement()
           
 
Method Summary
 java.lang.String getDir()
          gets the text direction
 java.lang.String getId()
          gets the ID of this element
 java.lang.String getLang()
          gets the language code of this element
 java.lang.String getName()
          gets the name of this element
 java.lang.String getOnBlur()
          gets the contents of the Javascript onFocus event
 java.lang.String getOnClick()
          gets the contents of the Javascript onClick event
 java.lang.String getOnDblClick()
          gets the contents of the Javascript onDblClick event
 java.lang.String getOnFocus()
          gets the contents of the Javascript onFocus event.
 java.lang.String getOnKeyDown()
          gets the contents of the Javascript onKeyDown event
 java.lang.String getOnKeyPress()
          gets the contents of the Javascript onKeyPress event
 java.lang.String getOnKeyUp()
          gets the contents of the Javascript onKeyUp event
 java.lang.String getOnMouseDown()
          gets the contents of the Javascript onMouseDown event
 java.lang.String getOnMouseMove()
          gets the contents of the Javascript onMouseOut event
 java.lang.String getOnMouseOut()
          gets the contents of the Javascript onMouseOut event
 java.lang.String getOnMouseOver()
          gets the contents of the Javascript onMouseOver event
 java.lang.String getOnMouseUp()
          gets the contents of the Javascript onMouseDown event
 java.lang.String getOnSelect()
          gets the contents of the Javascript onSelect event
 java.lang.String getStyle()
          gets the inline style information for this element
 java.lang.String getTabIndex()
          gets the tab index for this element
 java.lang.String getTheClass()
          gets the CSS class of this element
 java.lang.String getTitle()
          gets the title attribute for this element
 boolean getXhtml()
          returns the status of this element (whether it will output HTML or XHTML)
 void reset()
          resets all attributes of the element back to a blank state
 void setDir(java.lang.String x)
          sets the direction of the text.
 void setId(java.lang.String x)
          sets the ID of this element
 void setLang(java.lang.String x)
          sets the language code of this element
 void setName(java.lang.String x)
          sets the name of this element
 void setOnBlur(java.lang.String x)
          specifies the content of the Javascript onBlur event.
 void setOnClick(java.lang.String x)
          specifies the content of the Javascript onClick event.
 void setOnDblClick(java.lang.String x)
          specifies the content of the Javascript onDblClick event.
 void setOnFocus(java.lang.String x)
          specifies the content of the Javascript onFocus event.
 void setOnKeyDown(java.lang.String x)
          specifies the contents of the Javascript onKeyDown event.
 void setOnKeyPress(java.lang.String x)
          specifies the contents of the Javascript onKeyPress event.
 void setOnKeyUp(java.lang.String x)
          specifies the contents of the Javascript onKeyUp event.
 void setOnMouseDown(java.lang.String x)
          specifies the contents of the Javascript onMouseDown event.
 void setOnMouseMove(java.lang.String x)
          specifies the contents of the Javascript onMouseOut event.
 void setOnMouseOut(java.lang.String x)
          specifies the contents of the Javascript onMouseOut event.
 void setOnMouseOver(java.lang.String x)
          specifies the contents of the Javascript onMouseOver event.
 void setOnMouseUp(java.lang.String x)
          specifies the contents of the Javascript onMouseUp event.
 void setOnSelect(java.lang.String x)
          specifies the content of the Javascript onSelect event.
 void setStyle(java.util.Properties x)
          sets the inline style information for this element using a Properties file to hold the necessary attributes.
 void setStyle(java.lang.String x)
          sets the inline style information for this element by just specifying it as a String.
 void setTabIndex(int x)
          specifies the tab index for this element
 void setTheClass(java.lang.String x)
          sets the CSS class of this element
 void setTitle(java.lang.String x)
          sets the title attribute for this element
 void setXhtml(boolean x)
          sets the output type of this element.
 java.lang.String toString()
          Writes the attributes of this object to a string and returns them.
abstract  void write()
          Writes this element to Writer in this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

out

protected java.io.PrintWriter out

isXHTML

protected boolean isXHTML
Constructor Detail

HtmlFormElement

public HtmlFormElement()
Method Detail

setXhtml

public void setXhtml(boolean x)
sets the output type of this element. If this is true then XHTML will be written to the page (this usually just means that empty tags are terminated /> rather than just >.

See Also:
W3C reference

getXhtml

public boolean getXhtml()
returns the status of this element (whether it will output HTML or XHTML)


setName

public void setName(java.lang.String x)
sets the name of this element

See Also:
W3C Reference of this attribute

getName

public java.lang.String getName()
gets the name of this element

See Also:
W3C Reference of this attribute

setId

public void setId(java.lang.String x)
sets the ID of this element

See Also:
W3C Reference of this attribute

getId

public java.lang.String getId()
gets the ID of this element

See Also:
W3C Reference of this attribute

setTheClass

public void setTheClass(java.lang.String x)
sets the CSS class of this element

See Also:
W3C Reference of this attribute

getTheClass

public java.lang.String getTheClass()
gets the CSS class of this element

See Also:
W3C Reference of this attribute

setDir

public void setDir(java.lang.String x)
sets the direction of the text. Valid values are ltr and rtl.

See Also:
W3C Reference of this attribute

getDir

public java.lang.String getDir()
gets the text direction

See Also:
W3C Reference of this attribute

setLang

public void setLang(java.lang.String x)
sets the language code of this element

See Also:
W3C Reference of this attribute

getLang

public java.lang.String getLang()
gets the language code of this element

See Also:
W3C Reference of this attribute

setTitle

public void setTitle(java.lang.String x)
sets the title attribute for this element

See Also:
W3C Reference of this attribute

getTitle

public java.lang.String getTitle()
gets the title attribute for this element

See Also:
W3C Reference of this attribute

setStyle

public void setStyle(java.lang.String x)
sets the inline style information for this element by just specifying it as a String. This should be set according to the normal HTML spec, eg: border: 1px solid black; background-color: #ffff00

See Also:
W3C Reference of this attribute

setStyle

public void setStyle(java.util.Properties x)
sets the inline style information for this element using a Properties file to hold the necessary attributes. The key to the property will be used as the style name and the value will be used as the value.

eg: Properties p= new Properties();
p.setProperty("border", "1px solid black");
p.setProperty("background-color", "#ffff00");
would mean: border: 1px solid black; background-color: #ffff00

See Also:
W3C Reference of this attribute

getStyle

public java.lang.String getStyle()
gets the inline style information for this element

See Also:
W3C Reference of this attribute

setTabIndex

public void setTabIndex(int x)
specifies the tab index for this element

See Also:
W3C Reference of this attribute

getTabIndex

public java.lang.String getTabIndex()
gets the tab index for this element

See Also:
W3C Reference of this attribute

setOnFocus

public void setOnFocus(java.lang.String x)
specifies the content of the Javascript onFocus event. Note: If you write code with quotes inside a JS event, it must be single quotes (').

See Also:
W3C Reference of this attribute

getOnFocus

public java.lang.String getOnFocus()
gets the contents of the Javascript onFocus event. Note: If you write code with quotes inside a JS event, it must be single quotes (').

See Also:
W3C Reference of this attribute

setOnBlur

public void setOnBlur(java.lang.String x)
specifies the content of the Javascript onBlur event. Note: If you write code with quotes inside a JS event, it must be single quotes (').

See Also:
W3C Reference of this attribute

getOnBlur

public java.lang.String getOnBlur()
gets the contents of the Javascript onFocus event

See Also:
W3C Reference of this attribute

setOnSelect

public void setOnSelect(java.lang.String x)
specifies the content of the Javascript onSelect event. Note: If you write code with quotes inside a JS event, it must be single quotes (').

See Also:
W3C Reference of this attribute

getOnSelect

public java.lang.String getOnSelect()
gets the contents of the Javascript onSelect event

See Also:
W3C Reference of this attribute

setOnClick

public void setOnClick(java.lang.String x)
specifies the content of the Javascript onClick event. Note: If you write code with quotes inside a JS event, it must be single quotes (').

See Also:
W3C Reference of this attribute

getOnClick

public java.lang.String getOnClick()
gets the contents of the Javascript onClick event

See Also:
W3C Reference of this attribute

setOnDblClick

public void setOnDblClick(java.lang.String x)
specifies the content of the Javascript onDblClick event. Note: If you write code with quotes inside a JS event, it must be single quotes (').

See Also:
W3C Reference of this attribute

getOnDblClick

public java.lang.String getOnDblClick()
gets the contents of the Javascript onDblClick event

See Also:
W3C Reference of this attribute

setOnMouseDown

public void setOnMouseDown(java.lang.String x)
specifies the contents of the Javascript onMouseDown event. Note: If you write code with quotes inside a JS event, it must be single quotes (').

See Also:
W3C Reference of this attribute

getOnMouseDown

public java.lang.String getOnMouseDown()
gets the contents of the Javascript onMouseDown event

See Also:
W3C Reference of this attribute

setOnMouseUp

public void setOnMouseUp(java.lang.String x)
specifies the contents of the Javascript onMouseUp event. Note: If you write code with quotes inside a JS event, it must be single quotes (').

See Also:
W3C Reference of this attribute

getOnMouseUp

public java.lang.String getOnMouseUp()
gets the contents of the Javascript onMouseDown event

See Also:
W3C Reference of this attribute

setOnMouseOver

public void setOnMouseOver(java.lang.String x)
specifies the contents of the Javascript onMouseOver event. Note: If you write code with quotes inside a JS event, it must be single quotes (').

See Also:
W3C Reference of this attribute

getOnMouseOver

public java.lang.String getOnMouseOver()
gets the contents of the Javascript onMouseOver event

See Also:
W3C Reference of this attribute

setOnMouseMove

public void setOnMouseMove(java.lang.String x)
specifies the contents of the Javascript onMouseOut event. Note: If you write code with quotes inside a JS event, it must be single quotes (').

See Also:
W3C Reference of this attribute

getOnMouseMove

public java.lang.String getOnMouseMove()
gets the contents of the Javascript onMouseOut event

See Also:
W3C Reference of this attribute

setOnMouseOut

public void setOnMouseOut(java.lang.String x)
specifies the contents of the Javascript onMouseOut event. Note: If you write code with quotes inside a JS event, it must be single quotes (').

See Also:
W3C Reference of this attribute

getOnMouseOut

public java.lang.String getOnMouseOut()
gets the contents of the Javascript onMouseOut event

See Also:
W3C Reference of this attribute

setOnKeyPress

public void setOnKeyPress(java.lang.String x)
specifies the contents of the Javascript onKeyPress event. Note: If you write code with quotes inside a JS event, it must be single quotes (').

See Also:
W3C Reference of this attribute

getOnKeyPress

public java.lang.String getOnKeyPress()
gets the contents of the Javascript onKeyPress event

See Also:
W3C Reference of this attribute

setOnKeyDown

public void setOnKeyDown(java.lang.String x)
specifies the contents of the Javascript onKeyDown event. Note: If you write code with quotes inside a JS event, it must be single quotes (').

See Also:
W3C Reference of this attribute

getOnKeyDown

public java.lang.String getOnKeyDown()
gets the contents of the Javascript onKeyDown event

See Also:
W3C Reference of this attribute

setOnKeyUp

public void setOnKeyUp(java.lang.String x)
specifies the contents of the Javascript onKeyUp event. Note: If you write code with quotes inside a JS event, it must be single quotes (').

See Also:
W3C Reference of this attribute

getOnKeyUp

public java.lang.String getOnKeyUp()
gets the contents of the Javascript onKeyUp event

See Also:
W3C Reference of this attribute

write

public abstract void write()
Writes this element to Writer in this object. Eg if the HtmlText.write() method is called then a textbox with the appropriate attributes set will be written to the page.


toString

public java.lang.String toString()
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 java.lang.Object
See Also:
write()

reset

public void reset()
resets all attributes of the element back to a blank state