com.gargoylesoftware.htmlunit.html
Class HtmlOption

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.html.DomNode
      extended by com.gargoylesoftware.htmlunit.html.DomNamespaceNode
          extended by com.gargoylesoftware.htmlunit.html.HtmlElement
              extended by com.gargoylesoftware.htmlunit.html.StyledElement
                  extended by com.gargoylesoftware.htmlunit.html.ClickableElement
                      extended by com.gargoylesoftware.htmlunit.html.HtmlOption
All Implemented Interfaces:
DisabledElement, java.io.Serializable, java.lang.Cloneable

public class HtmlOption
extends ClickableElement
implements DisabledElement

Wrapper for the html element "option"

Version:
$Revision: 1.3 $
Author:
Mike Bowler, David K. Taylor, Christian Sell, David D. Kilzer, Marc Guillemot, Ahmed Ashour
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.gargoylesoftware.htmlunit.html.HtmlElement
HtmlElement.MapEntryWrappingIterator
 
Field Summary
static java.lang.String TAG_NAME
 the HTML tag represented by this element
 
Fields inherited from class com.gargoylesoftware.htmlunit.html.HtmlElement
ATTRIBUTE_NOT_DEFINED, ATTRIBUTE_VALUE_EMPTY
 
Fields inherited from class com.gargoylesoftware.htmlunit.html.DomNode
PROPERTY_ELEMENT, READY_STATE_COMPLETE, READY_STATE_INTERACTIVE, READY_STATE_LOADED, READY_STATE_LOADING, READY_STATE_UNINITIALIZED
 
Method Summary
 DomNode appendDomChild(DomNode node)
 append a child node to the end of the current list
 java.lang.String asText()
 Returns a text representation of this element that represents what would be visible to the user if this page was shown in a web browser. This implementation will show the label attribute before the content of the tag if the attribute exists.
 java.lang.String getDisabledAttribute()
 Return the value of the attribute "disabled".
 HtmlSelect getEnclosingSelect()
 Gets the enclosing select of this option
 java.lang.String getLabelAttribute()
 Return the value of the attribute "label".
 java.lang.String getSelectedAttribute()
 Return the value of the attribute "selected".
 java.lang.String getValueAttribute()
 Return the value of the attribute "value".
 void insertBefore(DomNode newNode)
 Inserts a new child node before this node into the child relationship this node is a part of.
 boolean isDefaultSelected()
 Return whether this Option is selected by default.
 boolean isDisabled()
 Return true if the disabled attribute is set for this element.
 boolean isSelected()
 Return true if this option is currently selected
 void reset()
 Reset the option to its original selected state.
 void setLabelAttribute(java.lang.String newLabel)
 Set the value of the attribute "label".
 Page setSelected(boolean selected)
 Set the selected state of this option.
 void setValueAttribute(java.lang.String newValue)
 Set the value of the attribute "value".
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.ClickableElement
click, click, dblClick, dblClick, getLangAttribute, getOnClickAttribute, getOnDblClickAttribute, getOnKeyDownAttribute, getOnKeyPressAttribute, getOnKeyUpAttribute, getOnMouseDownAttribute, getOnMouseMoveAttribute, getOnMouseOutAttribute, getOnMouseOverAttribute, getOnMouseUpAttribute, getTextDirectionAttribute, getXmlLangAttribute
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.StyledElement
getClassAttribute, getIdAttribute, getStyleAttribute, getTitleAttribute
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.HtmlElement
addHtmlAttributeChangeListener, appendChildIfNoneExists, cloneDomNode, fireEvent, fireEvent, getAttributeEntriesIterator, getAttributeValue, getChildElementsIterator, getEnclosingElement, getEnclosingForm, getEnclosingFormOrDie, getEventHandler, getHtmlElementById, getHtmlElementsByAttribute, getHtmlElementsByTagName, getHtmlElementsByTagNames, getId, getNodeName, getNodeType, getOneHtmlElementByAttribute, getTagName, hasHtmlElementWithId, isAttributeDefined, keyDown, keyDown, mouseDown, mouseDown, mouseMove, mouseMove, mouseOut, mouseOut, mouseOver, mouseOver, mouseUp, mouseUp, removeAttribute, removeChild, removeEventHandler, removeHtmlAttributeChangeListener, rightClick, rightClick, setAttributeValue, setEventHandler, setEventHandler, setId, toString
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.DomNamespaceNode
getLocalName, getNamespaceURI, getPrefix, getQualifiedName, setPrefix
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.DomNode
addDomChangeListener, asXml, getAllHtmlChildElements, getByXPath, getChildIterator, getEndColumnNumber, getEndLineNumber, getFirstDomChild, getLastDomChild, getNextDomSibling, getNodeValue, getPage, getParentDomNode, getPreviousDomSibling, getReadyState, getScriptObject, getStartColumnNumber, getStartLineNumber, remove, removeAllChildren, removeDomChangeListener, replace, setNodeValue, setReadyState, setScriptObject
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TAG_NAME

public static final java.lang.String TAG_NAME
the HTML tag represented by this element

See Also:
Constant Field Values
Method Detail

appendDomChild

public DomNode appendDomChild(DomNode node)
append a child node to the end of the current list

Overrides:
appendDomChild in class DomNode
Parameters:
node - the node to append
Returns:
the node added

asText

public java.lang.String asText()
Returns a text representation of this element that represents what would be visible to the user if this page was shown in a web browser. For example, a single-selection select element would return the currently selected value as text. This implementation will show the label attribute before the content of the tag if the attribute exists.

Overrides:
asText in class DomNode
Returns:
The element as text.

getDisabledAttribute

public final java.lang.String getDisabledAttribute()
Return the value of the attribute "disabled". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Specified by:
getDisabledAttribute in interface DisabledElement
Returns:
The value of the attribute "disabled" or an empty string if that attribute isn't defined.

getEnclosingSelect

public HtmlSelect getEnclosingSelect()
Gets the enclosing select of this option

Returns:
null if no select is found (for instance malformed html)

getLabelAttribute

public final java.lang.String getLabelAttribute()
Return the value of the attribute "label". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
The value of the attribute "label" or an empty string if that attribute isn't defined.

getSelectedAttribute

public final java.lang.String getSelectedAttribute()
Return the value of the attribute "selected". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
The value of the attribute "selected" or an empty string if that attribute isn't defined.

getValueAttribute

public final java.lang.String getValueAttribute()
Return the value of the attribute "value". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
The value of the attribute "value"
See Also:
initial value if value attribute is not set

insertBefore

public void insertBefore(DomNode newNode)
                  throws java.lang.IllegalStateException
Inserts a new child node before this node into the child relationship this node is a part of.

Overrides:
insertBefore in class DomNode
Parameters:
newNode - the new node to insert
Throws:
java.lang.IllegalStateException - if this node is not a child of any other node
See Also:
DomNode.insertBefore(DomNode)

isDefaultSelected

public final boolean isDefaultSelected()
Return whether this Option is selected by default. That is whether the "selected" attribute exists when the Option is constructed. This also determines the value of getSelectedAttribute() after a reset() on the form.

Returns:
whether the option is selected by default.

isDisabled

public final boolean isDisabled()
Return true if the disabled attribute is set for this element.

Specified by:
isDisabled in interface DisabledElement
Returns:
Return true if this element is disabled.

isSelected

public boolean isSelected()
Return true if this option is currently selected

Returns:
See above

reset

public void reset()
Reset the option to its original selected state.


setLabelAttribute

public final void setLabelAttribute(java.lang.String newLabel)
Set the value of the attribute "label". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Parameters:
newLabel - The value of the attribute "label".

setSelected

public Page setSelected(boolean selected)
Set the selected state of this option. This will possibly also change the selected properties of sibling option elements

Parameters:
selected - true if this option should be selected.
Returns:
The page that occupies this window after this change is made. It may be the same window or it may be a freshly loaded one.

setValueAttribute

public final void setValueAttribute(java.lang.String newValue)
Set the value of the attribute "value". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Parameters:
newValue - The value of the attribute "value".


Copyright © 2003-2016 AppPerfect Corporation. All Rights Reserved.