objectivehtml.htmlwidget
Class HtmlWidget

java.lang.Object
  |
  +--objectivehtml.oms.OMSObject
        |
        +--objectivehtml.htmlwidget.HtmlElement
              |
              +--objectivehtml.htmlwidget.HtmlWidget
Direct Known Subclasses:
HtmlContainerWidget, HtmlControlWidget, HtmlText

public abstract class HtmlWidget
extends HtmlElement

This abstract class is the base class of all the html widget classes.

A html widget represents a visual or interactive component of a html form.

All html widgets must have a parent widget, the only exception being the HtmlForm object which has no parent and is the top-most object. All HtmlWidget objects live within the context of a HtmlForm object. If a HtmlForm object has not been created then no other HtmlWidget objects can be created. A HtmlForm object cannot contain another HtmlForm object. Only HtmlContainerWidget objects can be parent objects.

All html widgets have a visibility flag. If a html widget object is visible then its html representation will be written out when the printHtml methods are called. If a html widget is invisible then its html representation is not written out. A widget cannot be made visible if its parent widget is invisible.

To remove a HtmlWidget object you should call the destroy method. Since Java has no destructors you must explicity call this method to correctly remove an object. The method will delink itself from its parent and clean up itself.

See Also:
setVisible(boolean), destroy(), HtmlContainerWidget, HtmlForm

Field Summary
protected  boolean m_bDestroyed
          Indicates whether the widget has been destroyed
protected  boolean m_bVisible
          Indicates the visibility of the widget
protected  HtmlForm m_objHtmlForm
          A reference to the form the widget is contained in
protected  HtmlContainerWidget m_objParentWidget
          A reference to the parent widget
 
Fields inherited from class objectivehtml.htmlwidget.HtmlElement
m_hmAttributes, m_sEndTag, m_sQuoteType, m_sStartTag
 
Constructor Summary
HtmlWidget()
          Creates an instance of the HtmlWidget object with no parent.
HtmlWidget(HtmlContainerWidget objParent)
          Creates an instance of the HtmlWidget object with the specified parent.
 
Method Summary
protected  void changeParent(HtmlContainerWidget objNewParent)
          Changes the parent of this object to be objNewParent.
protected  void changeParent(HtmlContainerWidget objNewParent, int nPosition)
          Changes the parent of this object to be objNewParent.
protected  void destroy()
          Removes this object from the form.
 java.lang.String getClassAttribute()
          Returns the style-sheet class of this object.
 HtmlForm getHtmlForm()
          Returns a reference to the HtmlForm object that contains this object.
 java.lang.String getID()
          Returns the ID of this object.
 java.lang.String getOnClick()
          Returns the onclick event of this object.
 java.lang.String getOnDblClick()
          Returns the ondblclick event of this object.
 java.lang.String getOnKeyDown()
          Returns the onkeydown event of this object.
 java.lang.String getOnKeyPress()
          Returns the onkeypress event of this object.
 java.lang.String getOnKeyUp()
          Returns the onkeyup event of this object.
 java.lang.String getOnMouseDown()
          Returns the onmousedown event of this object.
 java.lang.String getOnMouseMove()
          Returns the onmousemove event of this object.
 java.lang.String getOnMouseOut()
          Returns the onmouseout event of this object.
 java.lang.String getOnMouseOver()
          Returns the onmouseover event of this object.
 java.lang.String getOnMouseUp()
          Returns the onmouseup event of this object.
 HtmlContainerWidget getParent()
          Returns a reference to the parent of this object.
 java.lang.String getStyle()
          Returns the style of this object.
 boolean isDestroyed()
          Indicates whether this widget has been destroyed and should no longer be accessed.
 boolean isVisible()
          Returns the visibility of this object.
 void setClassAttribute(java.lang.String sClass)
          Sets the style-sheet class of this object.
 void setID(java.lang.String sID)
          Sets the ID of this object.
 void setOnClick(java.lang.String sOnClick)
          Sets the onclick event of this object.
 void setOnDblClick(java.lang.String sOnDblClick)
          Sets the ondblclick event of this object.
 void setOnKeyDown(java.lang.String sOnKeyDown)
          Sets the onkeydown event of this object.
 void setOnKeyPress(java.lang.String sOnKeyPress)
          Sets the onkeypress event of this object.
 void setOnKeyUp(java.lang.String sOnKeyUp)
          Sets the onkeyup event of this object.
 void setOnMouseDown(java.lang.String sOnMouseDown)
          Sets the onmousedown event of this object.
 void setOnMouseMove(java.lang.String sOnMouseMove)
          Sets the onmousemove event of this object.
 void setOnMouseOut(java.lang.String sOnMouseOut)
          Sets the onmouseout event of this object.
 void setOnMouseOver(java.lang.String sOnMouseOver)
          Sets the onmouseover event of this object.
 void setOnMouseUp(java.lang.String sOnMouseUp)
          Sets the onmouseup event of this object.
 void setStyle(java.lang.String sStyle)
          Sets the style of this object.
protected  void setVisible(boolean bVisible)
          Sets the visibility of this object.
 
Methods inherited from class objectivehtml.htmlwidget.HtmlElement
genEndTag, genStartTag, genStartTag, getAttribute, getAttributes, getBooleanAttribute, getQuoteType, printHtml, printHtml, printHtml, printHtml, printHtml, printHtml, printHtml, printHtml, setAttribute, setBooleanAttribute, setQuoteType, toString, toString
 
Methods inherited from class objectivehtml.oms.OMSObject
compareClasses, connect, disconnect, emit, isAlive, setAlive, signal, slot, slot
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_bVisible

protected boolean m_bVisible
Indicates the visibility of the widget

m_bDestroyed

protected boolean m_bDestroyed
Indicates whether the widget has been destroyed

m_objParentWidget

protected HtmlContainerWidget m_objParentWidget
A reference to the parent widget

m_objHtmlForm

protected HtmlForm m_objHtmlForm
A reference to the form the widget is contained in
Constructor Detail

HtmlWidget

public HtmlWidget(HtmlContainerWidget objParent)
           throws InvalidParentWidgetException,
                  InvalidChildWidgetException

Creates an instance of the HtmlWidget object with the specified parent.

The widget is created with the same visibility of its parent.

Parameters:
objParent - the parent widget
Throws:
InvalidParentWidgetException - if the specified parent widget is not valid
InvalidChildWidgetException - if the parent widget does not accept this widget as a child

HtmlWidget

public HtmlWidget()

Creates an instance of the HtmlWidget object with no parent. This version is used by HtmlForm class and should not be used by any other html widgets.

The default visibility is visible.

Method Detail

getParent

public HtmlContainerWidget getParent()
Returns a reference to the parent of this object.
Returns:
the parent of this html widget

getHtmlForm

public HtmlForm getHtmlForm()
Returns a reference to the HtmlForm object that contains this object.
Returns:
a reference to the HtmlForm containing this html widget

changeParent

protected void changeParent(HtmlContainerWidget objNewParent)
                     throws NotEqualsHtmlFormException,
                            InvalidChildWidgetException
Changes the parent of this object to be objNewParent. This object is appended to the new parent's list of child widgets.
Parameters:
objNewParent - a reference to the new parent object
Throws:
NotEqualsHtmlFormException - if the new parent belongs to a different HtmlForm object
InvalidChildWidgetException - if the new parent does not this widget to be a child

changeParent

protected void changeParent(HtmlContainerWidget objNewParent,
                            int nPosition)
                     throws NotEqualsHtmlFormException,
                            InvalidChildWidgetException
Changes the parent of this object to be objNewParent. This object is inserted (at position nPosition) into the new parent's list of child widgets.
Parameters:
objNewParent - a reference to the new parent object
nPosition - the position the new object is to be inserted into in the new parent
Throws:
NotEqualsHtmlFormException - if the new parent belongs to a different HtmlForm object
InvalidChildWidgetException - if the new parent does not this widget to be a child

setVisible

protected void setVisible(boolean bVisible)

Sets the visibility of this object.

By default this method should only be accessed by other classes of this library. If users are allowed to explicity show/hide this html widget then it needs to be made public. You can only make a widget visible if its parent widget is also visible.

Parameters:
bVisible - true indicates the object is visible, false indicates that the object is not visible
See Also:
isVisible()

isVisible

public boolean isVisible()
Returns the visibility of this object.
Returns:
true if the object is visible, false otherwise #see #setVisible(boolean)

setID

public void setID(java.lang.String sID)

Sets the ID of this object.

The html attribute it sets is "id".

If null is specified the attribute is cleared.

Parameters:
sID - the id for this element
See Also:
HtmlElement.setAttribute(String, String), getID()

getID

public java.lang.String getID()
Returns the ID of this object.
Returns:
the id for this element, null is returned if the attribute is not set
See Also:
setID(String), HtmlElement.getAttribute(String)

setClassAttribute

public void setClassAttribute(java.lang.String sClass)

Sets the style-sheet class of this object.

The html attribute it sets is "class".

If null is specified the attribute is cleared.

Parameters:
sClass - the class for this element
See Also:
HtmlElement.setAttribute(String, String), getClassAttribute()

getClassAttribute

public java.lang.String getClassAttribute()
Returns the style-sheet class of this object.
Returns:
the class for this element, null is returned if the attribute is not set
See Also:
setClassAttribute(String), HtmlElement.getAttribute(String)

setStyle

public void setStyle(java.lang.String sStyle)

Sets the style of this object.

The html attribute it sets is "style".

If null is specified the attribute is cleared.

Parameters:
sStyle - the style for this element
See Also:
HtmlElement.setAttribute(String, String), getStyle()

getStyle

public java.lang.String getStyle()
Returns the style of this object.
Returns:
the style for this element, null is returned if the attribute is not set
See Also:
setStyle(String), HtmlElement.getAttribute(String)

setOnClick

public void setOnClick(java.lang.String sOnClick)

Sets the onclick event of this object. The onclick event will fire when the html widget is clicked and will execute any client-side scripting code set.

The html attribute it sets is "onclick".

If null is specified the attribute is cleared.

Parameters:
sOnClick - the style for this element
See Also:
HtmlElement.setAttribute(String, String), getOnClick()

getOnClick

public java.lang.String getOnClick()
Returns the onclick event of this object.
Returns:
the onclick event for this element, null is returned if the attribute is not set
See Also:
setOnClick(String), HtmlElement.getAttribute(String)

setOnDblClick

public void setOnDblClick(java.lang.String sOnDblClick)

Sets the ondblclick event of this object. The ondblclick event will fire when the html widget is double-clicked and will execute any client-side scripting code set.

The html attribute it sets is "ondblclick".

If null is specified the attribute is cleared.

Parameters:
sOnDblClick - the style for this element
See Also:
HtmlElement.setAttribute(String, String), getOnDblClick()

getOnDblClick

public java.lang.String getOnDblClick()
Returns the ondblclick event of this object.
Returns:
the ondblclick event for this element, null is returned if the attribute is not set
See Also:
setOnDblClick(String), HtmlElement.getAttribute(String)

setOnMouseDown

public void setOnMouseDown(java.lang.String sOnMouseDown)

Sets the onmousedown event of this object. The onmousedown event will fire when the html widget has the mouse button pressed over it and will execute any client-side scripting code set.

The html attribute it sets is "onmousedown".

If null is specified the attribute is cleared.

Parameters:
sOnMouseDown - the style for this element
See Also:
HtmlElement.setAttribute(String, String), getOnMouseDown()

getOnMouseDown

public java.lang.String getOnMouseDown()
Returns the onmousedown event of this object.
Returns:
the onmousedown event for this element, null is returned if the attribute is not set
See Also:
setOnMouseDown(String), HtmlElement.getAttribute(String)

setOnMouseUp

public void setOnMouseUp(java.lang.String sOnMouseUp)

Sets the onmouseup event of this object. The onmouseup event will fire when the html widget has the mouse button released over it and will execute any client-side scripting code set.

The html attribute it sets is "onmouseup".

If null is specified the attribute is cleared.

Parameters:
sOnMouseUp - the style for this element
See Also:
HtmlElement.setAttribute(String, String), getOnMouseUp()

getOnMouseUp

public java.lang.String getOnMouseUp()
Returns the onmouseup event of this object.
Returns:
the onmouseup event for this element, null is returned if the attribute is not set
See Also:
setOnMouseUp(String), HtmlElement.getAttribute(String)

setOnMouseOver

public void setOnMouseOver(java.lang.String sOnMouseOver)

Sets the onmouseover event of this object. The onmouseover event will fire when the html widget has the mouse pointer moved onto it and will execute any client-side scripting code set.

The html attribute it sets is "onmouseover".

If null is specified the attribute is cleared.

Parameters:
sOnMouseOver - the style for this element
See Also:
HtmlElement.setAttribute(String, String), getOnMouseOver()

getOnMouseOver

public java.lang.String getOnMouseOver()
Returns the onmouseover event of this object.
Returns:
the onmouseover event for this element, null is returned if the attribute is not set
See Also:
setOnMouseOver(String), HtmlElement.getAttribute(String)

setOnMouseMove

public void setOnMouseMove(java.lang.String sOnMouseMove)

Sets the onmousemove event of this object. The onmousemove event will fire when the html widget has the mouse pointer moved while over it and will execute any client-side scripting code set.

The html attribute it sets is "onmousemove".

If null is specified the attribute is cleared.

Parameters:
sOnMouseMove - the style for this element
See Also:
HtmlElement.setAttribute(String, String), getOnMouseMove()

getOnMouseMove

public java.lang.String getOnMouseMove()
Returns the onmousemove event of this object.
Returns:
the onmousemove event for this element, null is returned if the attribute is not set
See Also:
setOnMouseMove(String), HtmlElement.getAttribute(String)

setOnMouseOut

public void setOnMouseOut(java.lang.String sOnMouseOut)

Sets the onmouseout event of this object. The onmouseout event will fire when the html widget has the mouse pointer moved off it and will execute any client-side scripting code set.

The html attribute it sets is "onmouseout".

If null is specified the attribute is cleared.

Parameters:
sOnMouseOut - the style for this element
See Also:
HtmlElement.setAttribute(String, String), getOnMouseOut()

getOnMouseOut

public java.lang.String getOnMouseOut()
Returns the onmouseout event of this object.
Returns:
the onmouseout event for this element, null is returned if the attribute is not set
See Also:
setOnMouseOut(String), HtmlElement.getAttribute(String)

setOnKeyPress

public void setOnKeyPress(java.lang.String sOnKeyPress)

Sets the onkeypress event of this object. The onkeypress event will fire when the html widget has focus and a key is pressed and released and will execute any client-side scripting code set.

The html attribute it sets is "onkeypress".

If null is specified the attribute is cleared.

Parameters:
sOnKeyPress - the style for this element
See Also:
HtmlElement.setAttribute(String, String), getOnKeyPress()

getOnKeyPress

public java.lang.String getOnKeyPress()
Returns the onkeypress event of this object.
Returns:
the onkeypress event for this element, null is returned if the attribute is not set
See Also:
setOnKeyPress(String), HtmlElement.getAttribute(String)

setOnKeyDown

public void setOnKeyDown(java.lang.String sOnKeyDown)

Sets the onkeydown event of this object. The onkeydown event will fire when the html widget has focus and a key is pressed and will execute any client-side scripting code set.

The html attribute it sets is "onkeydown".

If null is specified the attribute is cleared.

Parameters:
sOnKeyDown - the style for this element
See Also:
HtmlElement.setAttribute(String, String), getOnKeyDown()

getOnKeyDown

public java.lang.String getOnKeyDown()
Returns the onkeydown event of this object.
Returns:
the onkeydown event for this element, null is returned if the attribute is not set
See Also:
setOnKeyDown(String), HtmlElement.getAttribute(String)

setOnKeyUp

public void setOnKeyUp(java.lang.String sOnKeyUp)

Sets the onkeyup event of this object. The onkeyup event will fire when the html widget has focus and a key is released and will execute any client-side scripting code set.

The html attribute it sets is "onkeyup".

If null is specified the attribute is cleared.

Parameters:
sOnKeyUp - the style for this element
See Also:
HtmlElement.setAttribute(String, String), getOnKeyUp()

getOnKeyUp

public java.lang.String getOnKeyUp()
Returns the onkeyup event of this object.
Returns:
the onkeyup event for this element, null is returned if the attribute is not set
See Also:
setOnKeyUp(String), HtmlElement.getAttribute(String)

destroy

protected void destroy()

Removes this object from the form. Since Java has no destructors you must explicity call this method to correctly remove an object. The method will delink itself from its parent and clean up itself.

By default this method should only be accessed by other classes of this library. If users are allowed to explicity destroy this html widget then it needs to be made public.

See Also:
isDestroyed()

isDestroyed

public boolean isDestroyed()

Indicates whether this widget has been destroyed and should no longer be accessed.

Returns:
true if widget has been destroyed, false otherwise
See Also:
destroy()