com.gargoylesoftware.htmlunit.html
Class ClickableElement

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.html.DomNode
      extended by com.gargoylesoftware.htmlunit.html.DomNamespaceNode
          extended by com.gargoylesoftware.htmlunit.html.DomElement
              extended by com.gargoylesoftware.htmlunit.html.HtmlElement
                  extended by com.gargoylesoftware.htmlunit.html.StyledElement
                      extended by com.gargoylesoftware.htmlunit.html.ClickableElement
All Implemented Interfaces:
Serializable, Cloneable, Element, Node
Direct Known Subclasses:
HtmlAddress, HtmlAnchor, HtmlArea, HtmlBlockQuote, HtmlBody, HtmlButton, HtmlCaption, HtmlCenter, HtmlDefinitionDescription, HtmlDefinitionList, HtmlDefinitionTerm, HtmlDeletedText, HtmlDirectory, HtmlDivision, HtmlFieldSet, HtmlForm, HtmlHeading1, HtmlHeading2, HtmlHeading3, HtmlHeading4, HtmlHeading5, HtmlHeading6, HtmlHorizontalRule, HtmlImage, HtmlInlineQuotation, HtmlInput, HtmlInsertedText, HtmlLabel, HtmlLegend, HtmlLink, HtmlListItem, HtmlMap, HtmlMenu, HtmlNoFrames, HtmlNoScript, HtmlObject, HtmlOption, HtmlOptionGroup, HtmlOrderedList, HtmlParagraph, HtmlPreformattedText, HtmlSelect, HtmlSpan, HtmlTable, HtmlTableCell, HtmlTableColumn, HtmlTableColumnGroup, HtmlTableRow, HtmlTextArea, HtmlUnknownElement, HtmlUnorderedList, TableRowGroup

public abstract class ClickableElement
extends StyledElement

Intermediate base class for "clickable" HTML elements. As defined HTML 4.01 documentation, this class is a base class for all HTML elements except these: applet, base, basefront, bdo, br, font, frame, frameset, head, html, iframe, isindex, meta, param, script, style, and title.

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

Nested Class Summary
 
Nested classes/interfaces inherited from class com.gargoylesoftware.htmlunit.html.HtmlElement
HtmlElement.ChildElementsIterator
 
Nested classes/interfaces inherited from class com.gargoylesoftware.htmlunit.html.DomNode
DomNode.ChildIterator, DomNode.DescendantElementsIterator
 
Field Summary
 
Fields inherited from class com.gargoylesoftware.htmlunit.html.HtmlElement
ATTRIBUTE_NOT_DEFINED, ATTRIBUTE_VALUE_EMPTY, TAB_INDEX_OUT_OF_BOUNDS
 
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
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
protected ClickableElement(String namespaceURI, String qualifiedName, HtmlPage page, Map<String,HtmlAttr> attributes)
          Creates an instance.
 
Method Summary
 Page click()
          Simulates clicking on this element, returning the page that occupies this element's window after the element has been clicked.
 Page click(boolean shiftKey, boolean ctrlKey, boolean altKey)
          Simulates clicking on this element, returning the page that occupies this element's window after the element has been clicked.
 Page click(com.gargoylesoftware.htmlunit.javascript.host.Event event)
          INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Simulates clicking on this element, returning the page that occupies this element's window after the element has been clicked.
 Page dblClick()
          Simulates double-clicking on this element, returning the page that occupies this element's window after the element has been double-clicked.
 Page dblClick(boolean shiftKey, boolean ctrlKey, boolean altKey)
          Simulates double-clicking on this element, returning the page that occupies this element's window after the element has been double-clicked.
protected  Page doClickAction(Page defaultPage)
          This method will be called if there either wasn't an onclick handler, or if there was one, but the result of that handler wasn't false.
 String getLangAttribute()
          Returns the value of the attribute "lang".
 String getOnClickAttribute()
          Returns the value of the attribute "onclick".
 String getOnDblClickAttribute()
          Returns the value of the attribute "ondblclick".
 String getOnKeyDownAttribute()
          Returns the value of the attribute "onkeydown".
 String getOnKeyPressAttribute()
          Returns the value of the attribute "onkeypress".
 String getOnKeyUpAttribute()
          Returns the value of the attribute "onkeyup".
 String getOnMouseDownAttribute()
          Returns the value of the attribute "onmousedown".
 String getOnMouseMoveAttribute()
          Returns the value of the attribute "onmousemove".
 String getOnMouseOutAttribute()
          Returns the value of the attribute "onmouseout".
 String getOnMouseOverAttribute()
          Returns the value of the attribute "onmouseover".
 String getOnMouseUpAttribute()
          Returns the value of the attribute "onmouseup".
 String getTextDirectionAttribute()
          Returns the value of the attribute "dir".
 String getXmlLangAttribute()
          Returns the value of the attribute "xml:lang".
protected  boolean isStateUpdateFirst()
          Returns true if state updates should be done before onclick event handling.
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.StyledElement
getClassAttribute, getIdAttribute, getStyleAttribute, getTitleAttribute, isRenderedVisible
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.HtmlElement
addHtmlAttributeChangeListener, appendChildIfNoneExists, blur, checkChildHierarchy, cloneNode, fireEvent, fireEvent, fireHtmlAttributeAdded, fireHtmlAttributeRemoved, fireHtmlAttributeReplaced, focus, getAttribute, getAttributeEntriesIterator, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getAttributesCollection, getAttributeValue, getChildElements, getChildElementsIterator, getElementsByTagName, getElementsByTagNameNS, getEnclosingElement, getEnclosingForm, getEnclosingFormOrDie, getEventHandler, getHtmlElementById, getHtmlElementsByAttribute, getHtmlElementsByTagName, getHtmlElementsByTagNames, getId, getNodeName, getNodeType, getOneHtmlElementByAttribute, getPage, getSchemaTypeInfo, getTabIndex, getTagName, hasAttribute, hasAttributeNS, hasAttributes, hasHtmlElementWithId, isAttributeDefined, isEmptyXmlTagExpanded, isSubmittableByEnter, mouseDown, mouseDown, mouseMove, mouseMove, mouseOut, mouseOut, mouseOver, mouseOver, mouseUp, mouseUp, preventDefault, printOpeningTagContentAsXml, printXml, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, removeEventHandler, removeHtmlAttributeChangeListener, rightClick, rightClick, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS, setAttributeValue, setAttributeValue, setEventHandler, setEventHandler, setId, setIdAttribute, setIdAttributeNode, setIdAttributeNS, toString, type, type, type, type
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.DomNamespaceNode
getLocalName, getNamespaceURI, getPrefix, getQualifiedName, setPrefix
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.DomNode
addDomChangeListener, appendChild, appendDomChild, asText, asXml, cloneDomNode, compareDocumentPosition, fireNodeAdded, fireNodeDeleted, getAllHtmlChildElements, getBaseURI, getByXPath, getCanonicalXPath, getChildIterator, getChildNodes, getChildren, getChildrenAsText, getEndColumnNumber, getEndLineNumber, getFeature, getFirstByXPath, getFirstChild, getFirstDomChild, getLastChild, getLastDomChild, getLog, getNextDomSibling, getNextSibling, getNodeValue, getOwnerDocument, getParentDomNode, getParentNode, getPreviousDomSibling, getPreviousSibling, getReadyState, getScriptObject, getStartColumnNumber, getStartLineNumber, getTextContent, getUserData, hasChildNodes, insertBefore, insertBefore, isAncestorOf, isDefaultNamespace, isEqualNode, isSameNode, isSupported, isTrimmedText, lookupNamespaceURI, lookupPrefix, normalize, notifyIncorrectness, onAddedToPage, onAllChildrenAddedToPage, printChildrenAsXml, reduceWhitespace, remove, removeAllChildren, removeChild, removeDomChangeListener, replace, replaceChild, setNextSibling, setNodeValue, setParentNode, setPreviousSibling, setReadyState, setScriptObject, setTextContent, setUserData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
appendChild, compareDocumentPosition, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData
 

Constructor Detail

ClickableElement

protected ClickableElement(String namespaceURI,
                           String qualifiedName,
                           HtmlPage page,
                           Map<String,HtmlAttr> attributes)
Creates an instance.

Parameters:
namespaceURI - the URI that identifies an XML namespace
qualifiedName - the qualified name of the element type to instantiate
page - the page that contains this element
attributes - the initial attributes
Method Detail

click

public Page click()
           throws IOException
Simulates clicking on this element, returning the page that occupies this element's window after the element has been clicked. Note that the returned page may or may not be the same as the original page, depending on the type of element being clicked, the presence of JavaScript action listeners, etc.

Returns:
the page that occupies this element's window after the element has been clicked
Throws:
IOException - if an IO error occurs

click

public Page click(boolean shiftKey,
                  boolean ctrlKey,
                  boolean altKey)
           throws IOException
Simulates clicking on this element, returning the page that occupies this element's window after the element has been clicked. Note that the returned page may or may not be the same as the original page, depending on the type of element being clicked, the presence of JavaScript action listeners, etc.

Parameters:
shiftKey - true if SHIFT is pressed during the click
ctrlKey - true if CTRL is pressed during the click
altKey - true if ALT is pressed during the click
Returns:
the page that occupies this element's window after the element has been clicked
Throws:
IOException - if an IO error occurs

click

public Page click(com.gargoylesoftware.htmlunit.javascript.host.Event event)
           throws IOException
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Simulates clicking on this element, returning the page that occupies this element's window after the element has been clicked. Note that the returned page may or may not be the same as the original page, depending on the type of element being clicked, the presence of JavaScript action listeners, etc.

Parameters:
event - the click event used
Returns:
the page that occupies this element's window after the element has been clicked
Throws:
IOException - if an IO error occurs

dblClick

public Page dblClick()
              throws IOException
Simulates double-clicking on this element, returning the page that occupies this element's window after the element has been double-clicked. Note that the returned page may or may not be the same as the original page, depending on the type of element being clicked, the presence of JavaScript action listeners, etc. Note also that click() is automatically called first.

Returns:
the page that occupies this element's window after the element has been double-clicked
Throws:
IOException - if an IO error occurs

dblClick

public Page dblClick(boolean shiftKey,
                     boolean ctrlKey,
                     boolean altKey)
              throws IOException
Simulates double-clicking on this element, returning the page that occupies this element's window after the element has been double-clicked. Note that the returned page may or may not be the same as the original page, depending on the type of element being clicked, the presence of JavaScript action listeners, etc. Note also that click(boolean, boolean, boolean) is automatically called first.

Parameters:
shiftKey - true if SHIFT is pressed during the double-click
ctrlKey - true if CTRL is pressed during the double-click
altKey - true if ALT is pressed during the double-click
Returns:
the page that occupies this element's window after the element has been double-clicked
Throws:
IOException - if an IO error occurs

doClickAction

protected Page doClickAction(Page defaultPage)
                      throws IOException

This method will be called if there either wasn't an onclick handler, or if there was one, but the result of that handler wasn't false. This is the default behavior of clicking the element.

The default implementation returns the current page. Subclasses requiring different behavior (like HtmlSubmitInput) will override this method.

Parameters:
defaultPage - the default page to return if the action does not load a new page
Returns:
the page that is currently loaded after execution of this method
Throws:
IOException - if an IO error occurs

getLangAttribute

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

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

getXmlLangAttribute

public final String getXmlLangAttribute()
Returns the value of the attribute "xml:lang". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Returns:
the value of the attribute "xml:lang" or an empty string if that attribute isn't defined

getTextDirectionAttribute

public final String getTextDirectionAttribute()
Returns the value of the attribute "dir". Refer to the HTML 4.01 documentation for details on the use of this attribute.

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

getOnClickAttribute

public final String getOnClickAttribute()
Returns the value of the attribute "onclick". Refer to the HTML 4.01 documentation for details on the use of this attribute.

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

getOnDblClickAttribute

public final String getOnDblClickAttribute()
Returns the value of the attribute "ondblclick". Refer to the HTML 4.01 documentation for details on the use of this attribute.

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

getOnMouseDownAttribute

public final String getOnMouseDownAttribute()
Returns the value of the attribute "onmousedown". Refer to the HTML 4.01 documentation for details on the use of this attribute.

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

getOnMouseUpAttribute

public final String getOnMouseUpAttribute()
Returns the value of the attribute "onmouseup". Refer to the HTML 4.01 documentation for details on the use of this attribute.

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

getOnMouseOverAttribute

public final String getOnMouseOverAttribute()
Returns the value of the attribute "onmouseover". Refer to the HTML 4.01 documentation for details on the use of this attribute.

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

getOnMouseMoveAttribute

public final String getOnMouseMoveAttribute()
Returns the value of the attribute "onmousemove". Refer to the HTML 4.01 documentation for details on the use of this attribute.

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

getOnMouseOutAttribute

public final String getOnMouseOutAttribute()
Returns the value of the attribute "onmouseout". Refer to the HTML 4.01 documentation for details on the use of this attribute.

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

getOnKeyPressAttribute

public final String getOnKeyPressAttribute()
Returns the value of the attribute "onkeypress". Refer to the HTML 4.01 documentation for details on the use of this attribute.

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

getOnKeyDownAttribute

public final String getOnKeyDownAttribute()
Returns the value of the attribute "onkeydown". Refer to the HTML 4.01 documentation for details on the use of this attribute.

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

getOnKeyUpAttribute

public final String getOnKeyUpAttribute()
Returns the value of the attribute "onkeyup". Refer to the HTML 4.01 documentation for details on the use of this attribute.

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

isStateUpdateFirst

protected boolean isStateUpdateFirst()
Returns true if state updates should be done before onclick event handling. This method returns false by default, and is expected to be overridden to return true by derived classes like HtmlCheckBoxInput.

Returns:
true if state updates should be done before onclick event handling


Copyright © 2002-2008 Gargoyle Software Inc.. All Rights Reserved.