objectivehtml.htmlwidget
Class HtmlOptionItem

java.lang.Object
  |
  +--objectivehtml.oms.OMSObject
        |
        +--objectivehtml.htmlwidget.HtmlElement
              |
              +--objectivehtml.htmlwidget.HtmlOptionItem

public class HtmlOptionItem
extends HtmlElement

This class holds the data for an option item element in a select box. i.e.

<option ...>

The object can only exist within the context of a HtmlListBox object. Each option item has 2 components, the value and option text components. The value is what is used internally by the form to identify the option item, where as the option text is what is displayed to the client. The value of each option item must be unique for the object to correctly identify the selected values of the list box.

If auto-escape is turned on (default) then the value and option text are escaped before being written out (using HtmlUtils.htmlSpecialChars(String)).

The object can be either selected or unselected. This is used by the parent HtmlListBox object to determine which option items are chosen.

See Also:
HtmlUtils.htmlSpecialChars(String)

Fields inherited from class objectivehtml.htmlwidget.HtmlElement
m_hmAttributes, m_sEndTag, m_sQuoteType, m_sStartTag
 
Constructor Summary
protected HtmlOptionItem(HtmlListBox objParent)
          Constructs an instance of HtmlOptionItem.
 
Method Summary
protected  java.lang.String genStartTag(int nOutputType)
          Generates the start tag with all the attribute values that have been set for this object.
 HtmlListBox getHtmlListBox()
          Returns a reference to the HtmlListBox object that this option is contained within.
 java.lang.String getOptionText()
          Returns the option text of this option item.
 java.lang.String getValue()
          Returns the value of this option item.
 boolean isAutoEscape()
          Returns whether the auto-escape feature is on or not.
 boolean isSelected()
          Returns whether the option item is selected/unselected.
 void printHtml(javax.servlet.jsp.JspWriter objWriter, int nOutputType)
          Prints the html that represents this object to the output stream.
 void printHtml(java.io.PrintWriter objWriter, int nOutputType)
          Prints the html that represents this object to the output stream.
 void setAutoEscape(boolean bAutoEscape)
          Sets the auto-escape feature to be either on (default) or off.
 void setBooleanAttribute(java.lang.String sAttribute, boolean bIsOn)
          Sets a html boolean-attribute for this object.
 void setOptionText(java.lang.String sOptionText)
          Sets the option text of this option item.
 void setSelected(boolean bSelected)
          Sets the option item to selected/unselected.
 void setValue(java.lang.String sValue)
          Sets the value for this option item.
 
Methods inherited from class objectivehtml.htmlwidget.HtmlElement
genEndTag, genStartTag, getAttribute, getAttributes, getBooleanAttribute, getQuoteType, printHtml, printHtml, printHtml, printHtml, printHtml, printHtml, setAttribute, 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
 

Constructor Detail

HtmlOptionItem

protected HtmlOptionItem(HtmlListBox objParent)
                  throws InvalidParentElementException
Constructs an instance of HtmlOptionItem.
Parameters:
objParent - the parent of this element
Throws:
InvalidParentElementException - if the specified parent element is not valid
Method Detail

getHtmlListBox

public HtmlListBox getHtmlListBox()
Returns a reference to the HtmlListBox object that this option is contained within.
Returns:
the html list box parent

setAutoEscape

public void setAutoEscape(boolean bAutoEscape)
Sets the auto-escape feature to be either on (default) or off. If auto-escape is set as true then the value and option text components of the option item will have any html entity characters escaped with the HtmlUtils.htmlSpecialChars(String) method.
Parameters:
bAutoEscape - true if you want auto-escape on (default), false otherwise
See Also:
HtmlUtils.htmlSpecialChars(String), isAutoEscape()

isAutoEscape

public boolean isAutoEscape()
Returns whether the auto-escape feature is on or not.
Returns:
true if auto-escape is on, false otherwise
See Also:
setAutoEscape(boolean)

getValue

public java.lang.String getValue()
Returns the value of this option item.
Returns:
the value for this element, null is returned if the attribute is not set
See Also:
setValue(String), HtmlElement.getAttribute(String)

setValue

public void setValue(java.lang.String sValue)

Sets the value for this option item.

The html attribute it sets is "value".

If null is specified the attribute is cleared.

Parameters:
sValue - the value for this element
See Also:
HtmlElement.setAttribute(String, String), getValue()

getOptionText

public java.lang.String getOptionText()
Returns the option text of this option item.
Returns:
the option text value of this option item.
See Also:
setOptionText(String)

setOptionText

public void setOptionText(java.lang.String sOptionText)
Sets the option text of this option item.
Parameters:
sOptionText - the option text for this item
See Also:
getOptionText()

setSelected

public void setSelected(boolean bSelected)

Sets the option item to selected/unselected.

The html attribute it sets is "selected".

If null is specified the attribute is cleared.

Parameters:
bSelected - true for selected, false otherwise
See Also:
setBooleanAttribute(String, boolean), isSelected()

isSelected

public boolean isSelected()
Returns whether the option item is selected/unselected.
Returns:
true if selected, false otherwise
See Also:
setSelected(boolean), HtmlElement.getBooleanAttribute(String)

genStartTag

protected java.lang.String genStartTag(int nOutputType)

Generates the start tag with all the attribute values that have been set for this object.

This method is used internally by the printHtml methods to generate the output strings.

Overrides:
genStartTag in class HtmlElement
Parameters:
nOutputType - the output type
Returns:
the start tag with all the attribute values

printHtml

public void printHtml(java.io.PrintWriter objWriter,
                      int nOutputType)
               throws java.io.IOException
Prints the html that represents this object to the output stream.
Overrides:
printHtml in class HtmlElement
Parameters:
objWriter - the output stream for a Servlet object
nOutputType - the output type
Throws:
java.io.IOException - if it cannot write the output

printHtml

public void printHtml(javax.servlet.jsp.JspWriter objWriter,
                      int nOutputType)
               throws java.io.IOException
Prints the html that represents this object to the output stream.
Overrides:
printHtml in class HtmlElement
Parameters:
objWriter - the output stream for a Jsp page
nOutputType - the output type
Throws:
java.io.IOException - if it cannot write the output

setBooleanAttribute

public void setBooleanAttribute(java.lang.String sAttribute,
                                boolean bIsOn)
                         throws InvalidAttributeException

Sets a html boolean-attribute for this object. The name of the attribute is case-insensitive.

Overrides:
setBooleanAttribute in class HtmlElement
Parameters:
sName - the name of the attribute
bIsOn - true if attribute should be set, if false is specified then the attribute is cleared
Throws:
InvalidAttributeException - if the name is not valid