com.gargoylesoftware.htmlunit.html
Class HtmlCheckBoxInput

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
                          extended by com.gargoylesoftware.htmlunit.html.FocusableElement
                              extended by com.gargoylesoftware.htmlunit.html.HtmlInput
                                  extended by com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput
All Implemented Interfaces:
DisabledElement, SubmittableElement, Serializable, Cloneable

public class HtmlCheckBoxInput
extends HtmlInput

Wrapper for the html element "input"

Version:
$Revision: 2132 $
Author:
Mike Bowler, David K. Taylor, Jun Chen, Christian Sell, Marc Guillemot, Mike Bresnahan, Daniel Gredler, Ahmed Ashour
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.gargoylesoftware.htmlunit.html.HtmlElement
HtmlElement.ChildElementsIterator, HtmlElement.MapEntryWrappingIterator
 
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.HtmlInput
TAG_NAME
 
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
ATTRIBUTE_NODE, COMMENT_NODE, DOCUMENT_NODE, ELEMENT_NODE, PROPERTY_ELEMENT, READY_STATE_COMPLETE, READY_STATE_INTERACTIVE, READY_STATE_LOADED, READY_STATE_LOADING, READY_STATE_UNINITIALIZED, TEXT_NODE
 
Constructor Summary
HtmlCheckBoxInput(HtmlPage page, Map attributes)
          Deprecated. You should not directly construct HtmlCheckBoxInput.
 
Method Summary
 String asText()
          A checkbox does not have a textual representation, but we invent one for it because it is useful for testing.
protected  Page doClickAction(Page defaultPage)
          Override so that checkbox can change its state correctly when its click() method is called.
 boolean isDefaultChecked()
          Returns the default checked state to use when this element gets reset, if applicable. The default implementation returns false; only checkboxes and radio buttons really care what the default checked value is.
protected  boolean isStateUpdateFirst()
          Both IE and Mozilla will first update the internal state of checkbox and then handle "onclick" event.
protected  void preventDefault()
          This method is called if the current fired event is canceled by preventDefault() in FireFox, or by returning false in Internet Explorer.
 void reset()
          Return the value of this element to the default value or checked state (usually what it was at the time the page was loaded, unless it has been modified via JavaScript).
 Page setChecked(boolean isChecked)
          Set the "checked" attribute
 void setDefaultChecked(boolean defaultChecked)
          Sets the default checked state to use when this element gets reset, if applicable. The default implementation is empty; only checkboxes and radio buttons really care what the default checked value is.
 void setDefaultValue(String defaultValue)
          Sets the default value to use when this element gets reset, if applicable. Also sets the value attribute when emulating Netscape browsers. Also sets the value to the new default value.
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.HtmlInput
click, getAcceptAttribute, getAccessKeyAttribute, getAlignAttribute, getAltAttribute, getCheckedAttribute, getDefaultValue, getDisabledAttribute, getMaxLengthAttribute, getNameAttribute, getOnBlurAttribute, getOnChangeAttribute, getOnFocusAttribute, getOnSelectAttribute, getReadOnlyAttribute, getSizeAttribute, getSrcAttribute, getSubmitKeyValuePairs, getTabIndexAttribute, getTypeAttribute, getUseMapAttribute, getValueAttribute, isChecked, isDisabled, setDefaultValue, setValueAttribute
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.ClickableElement
click, 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, isRenderedVisible
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.HtmlElement
addHtmlAttributeChangeListener, appendChildIfNoneExists, assertNotEmpty, blur, cloneDomNode, cloneNode, fireEvent, fireEvent, fireHtmlAttributeAdded, fireHtmlAttributeRemoved, fireHtmlAttributeReplaced, focus, getAttribute, getAttributeEntriesIterator, getAttributeNS, getAttributeValue, getChildElementsIterator, getEnclosingElement, getEnclosingForm, getEnclosingFormOrDie, getEventHandler, getHtmlElementById, getHtmlElementsByAttribute, getHtmlElementsByTagName, getHtmlElementsByTagNames, getId, getNodeName, getNodeType, getOneHtmlElementByAttribute, getTabIndex, getTagName, hasAttribute, hasAttributeNS, hasAttributes, hasHtmlElementWithId, isAttributeDefined, isEmptyXmlTagExpanded, isSubmittableByEnter, keyDown, keyDown, mouseDown, mouseDown, mouseMove, mouseMove, mouseOut, mouseOut, mouseOver, mouseOver, mouseUp, mouseUp, notImplemented, printOpeningTagContentAsXml, printXml, removeAttribute, removeAttributeNS, removeChild, removeEventHandler, removeHtmlAttributeChangeListener, rightClick, rightClick, setAttribute, setAttributeNS, setAttributeValue, setAttributeValue, setEventHandler, setEventHandler, setId, 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, addPropertyChangeListener, appendChild, appendDomChild, asXml, fireNodeAdded, fireNodeDeleted, firePropertyChange, getAllHtmlChildElements, getByXPath, getChildIterator, getChildrenAsText, getEndColumnNumber, getEndLineNumber, getFirstByXPath, getFirstChild, getFirstDomChild, getLastChild, getLastDomChild, getLog, getNativePage, getNextDomSibling, getNextSibling, getNodeValue, getPage, getParentDomNode, getParentNode, getPreviousDomSibling, getPreviousSibling, getReadyState, getScriptObject, getStartColumnNumber, getStartLineNumber, insertBefore, isAncestorOf, isTrimmedText, notifyIncorrectness, onAddedToPage, onAllChildrenAddedToPage, printChildrenAsXml, reduceWhitespace, remove, removeAllChildren, removeDomChangeListener, removePropertyChangeListener, replace, setNextSibling, setNodeValue, setParentNode, setPreviousSibling, setReadyState, setScriptObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HtmlCheckBoxInput

public HtmlCheckBoxInput(HtmlPage page,
                         Map attributes)
Deprecated. You should not directly construct HtmlCheckBoxInput.

Create an instance. If no value is specified, it is set to "on" as browsers do (e.g. IE6 and Mozilla 1.7) even if spec says that it is not allowed (W3C).

Parameters:
page - The page that contains this element
attributes - the initial attributes
Method Detail

reset

public void reset()
Return the value of this element to the default value or checked state (usually what it was at the time the page was loaded, unless it has been modified via JavaScript).

Specified by:
reset in interface SubmittableElement
Overrides:
reset in class HtmlInput
See Also:
SubmittableElement.reset()

setChecked

public Page setChecked(boolean isChecked)
Set the "checked" attribute

Overrides:
setChecked in class HtmlInput
Parameters:
isChecked - true if this element is to be selected
Returns:
The page that occupies this window after setting checked status. It may be the same window or it may be a freshly loaded one.

asText

public String asText()
A checkbox does not have a textual representation, but we invent one for it because it is useful for testing.

Overrides:
asText in class HtmlInput
Returns:
"checked" or "unchecked" according to the radio state

doClickAction

protected Page doClickAction(Page defaultPage)
                      throws IOException
Override so that checkbox can change its state correctly when its click() method is called. This method will be called if there either wasn't an onclick handler or there was 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.

Overrides:
doClickAction in class ClickableElement
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 occurred

isStateUpdateFirst

protected boolean isStateUpdateFirst()
Both IE and Mozilla will first update the internal state of checkbox and then handle "onclick" event. Return true if the state update should be done before onclick event handling. This is expected to be overridden to return "true" by derived classes like HtmlCheckBoxInput.

Overrides:
isStateUpdateFirst in class ClickableElement
Returns:
Return true if state update should be done first.

preventDefault

protected void preventDefault()
This method is called if the current fired event is canceled by preventDefault() in FireFox, or by returning false in Internet Explorer. The default implementation does nothing.

Overrides:
preventDefault in class HtmlElement

setDefaultValue

public void setDefaultValue(String defaultValue)
Sets the default value to use when this element gets reset, if applicable. Also sets the value attribute when emulating Netscape browsers. Also sets the value to the new default value.

Specified by:
setDefaultValue in interface SubmittableElement
Overrides:
setDefaultValue in class HtmlInput
Parameters:
defaultValue - The default value to use when this element gets reset, if applicable.
See Also:
SubmittableElement.setDefaultValue(String)

setDefaultChecked

public void setDefaultChecked(boolean defaultChecked)
Sets the default checked state to use when this element gets reset, if applicable. The default implementation is empty; only checkboxes and radio buttons really care what the default checked value is.

Specified by:
setDefaultChecked in interface SubmittableElement
Overrides:
setDefaultChecked in class HtmlInput
Parameters:
defaultChecked - The default checked state to use when this element gets reset, if applicable.
See Also:
SubmittableElement.setDefaultChecked(boolean)

isDefaultChecked

public boolean isDefaultChecked()
Returns the default checked state to use when this element gets reset, if applicable. The default implementation returns false; only checkboxes and radio buttons really care what the default checked value is.

Specified by:
isDefaultChecked in interface SubmittableElement
Overrides:
isDefaultChecked in class HtmlInput
Returns:
The default checked state to use when this element gets reset, if applicable.
See Also:
SubmittableElement.isDefaultChecked()


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