com.gargoylesoftware.htmlunit.html
Class HtmlForm

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.HtmlForm
All Implemented Interfaces:
Serializable, Cloneable, Element, Node

public class HtmlForm
extends HtmlElement

Wrapper for the HTML element "form".

Version:
$Revision: 5942 $
Author:
Mike Bowler, David K. Taylor, Brad Clarke, Christian Sell, Marc Guillemot, George Murnock, Kent Tong, Ahmed Ashour, Philip Graf
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<T extends DomNode>
 
Field Summary
static String TAG_NAME
          The HTML tag represented by this element.
 
Fields inherited from class com.gargoylesoftware.htmlunit.html.HtmlElement
TAB_INDEX_OUT_OF_BOUNDS
 
Fields inherited from class com.gargoylesoftware.htmlunit.html.DomElement
ATTRIBUTE_NOT_DEFINED, ATTRIBUTE_VALUE_EMPTY
 
Fields inherited from class com.gargoylesoftware.htmlunit.html.DomNode
AS_TEXT_BLANK, AS_TEXT_BLOCK_SEPARATOR, AS_TEXT_NEW_LINE, AS_TEXT_TAB, 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
 
Method Summary
 String getAcceptAttribute()
          Returns the value of the attribute "accept".
 String getAcceptCharsetAttribute()
          Returns the value of the attribute "accept-charset".
 String getActionAttribute()
          Returns the value of the attribute "action".
 HtmlButton getButtonByName(String name)
          Returns the first HtmlButton element in this form that has the specified name.
 List<HtmlButton> getButtonsByName(String name)
          Returns all the HtmlButton elements in this form that have the specified name.
 HtmlRadioButtonInput getCheckedRadioButton(String name)
          Returns the first checked radio button with the specified name.
 String getEnctypeAttribute()
          Returns the value of the attribute "enctype".
<I extends HtmlInput>
I
getInputByName(String name)
          Returns the first input element which is a member of this form and has the specified name.
<I extends HtmlInput>
I
getInputByValue(String value)
          Returns the first input in this form with the specified value.
 List<HtmlInput> getInputsByName(String name)
          Returns all input elements which are members of this form and have the specified name.
 List<HtmlInput> getInputsByValue(String value)
          Returns all the inputs in this form with the specified value.
 List<HtmlElement> getLostChildren()
          Gets the form elements that may be submitted but that don't belong to the form's children in the DOM due to incorrect HTML code.
 String getMethodAttribute()
          Returns the value of the attribute "method".
 String getNameAttribute()
          Returns the value of the attribute "name".
 String getOnResetAttribute()
          Returns the value of the attribute "onreset".
 String getOnSubmitAttribute()
          Returns the value of the attribute "onsubmit".
 List<HtmlRadioButtonInput> getRadioButtonsByName(String name)
          Returns all the HtmlRadioButtonInput elements in this form that have the specified name.
 HtmlSelect getSelectByName(String name)
          Returns the first HtmlSelect element in this form that has the specified name.
 List<HtmlSelect> getSelectsByName(String name)
          Returns all the HtmlSelect elements in this form that have the specified name.
 String getTargetAttribute()
          Returns the value of the attribute "target".
 HtmlTextArea getTextAreaByName(String name)
          Returns the first HtmlTextArea element in this form that has the specified name.
 List<HtmlTextArea> getTextAreasByName(String name)
          Returns all the HtmlTextArea elements in this form that have the specified name.
 WebRequest getWebRequest(SubmittableElement submitElement)
          INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Gets the request for a submission of this form with the specified SubmittableElement.
 WebRequest getWebRequestSettings(SubmittableElement submitElement)
          Deprecated. as of 2.8, please use getWebRequest(SubmittableElement) instead
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.
 Page reset()
          Resets this form to its initial values, returning the page contained by this form's window after the reset.
 void setActionAttribute(String action)
          Sets the value of the attribute "action".
 void setEnctypeAttribute(String encoding)
          Sets the value of the attribute "enctype".
 void setMethodAttribute(String method)
          Sets the value of the attribute "method".
 void setNameAttribute(String name)
          Sets the value of the attribute "name".
 void setTargetAttribute(String target)
          Sets the value of the attribute "target".
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.HtmlElement
addHtmlAttributeChangeListener, appendChildIfNoneExists, blur, checkChildHierarchy, click, click, click, dblClick, dblClick, doClickAction, doType, fireEvent, fireEvent, fireHtmlAttributeAdded, fireHtmlAttributeRemoved, fireHtmlAttributeReplaced, focus, getCanonicalXPath, getChildElements, getElementById, getElementsByAttribute, getEnclosingElement, getEnclosingForm, getEnclosingFormOrDie, getEventTargetElement, getHtmlElementsByTagName, getHtmlElementsByTagNames, getId, getLangAttribute, getNodeName, getOnClickAttribute, getOnDblClickAttribute, getOneHtmlElementByAttribute, getOnKeyDownAttribute, getOnKeyPressAttribute, getOnKeyUpAttribute, getOnMouseDownAttribute, getOnMouseMoveAttribute, getOnMouseOutAttribute, getOnMouseOverAttribute, getOnMouseUpAttribute, getTabIndex, getTextDirectionAttribute, getXmlLangAttribute, hasEventHandlers, hasHtmlElementWithId, isAttributeCaseSensitive, isStateUpdateFirst, isSubmittableByEnter, mouseDown, mouseDown, mouseMove, mouseMove, mouseOut, mouseOut, mouseOver, mouseOver, mouseUp, mouseUp, removeAttribute, removeChild, removeEventHandler, removeHtmlAttributeChangeListener, rightClick, rightClick, setAttributeNS, setEventHandler, setEventHandler, setId, toString, type, type, type, type
 
Methods inherited from class com.gargoylesoftware.htmlunit.html.DomElement
cloneNode, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getAttributesMap, getElementsByTagName, getElementsByTagNameNS, getNodeType, getSchemaTypeInfo, getTagName, hasAttribute, hasAttributeNS, hasAttributes, isEmptyXmlTagExpanded, namespaces, printOpeningTagContentAsXml, printXml, removeAttributeNode, removeAttributeNS, setAttribute, setAttributeNode, setAttributeNodeNS, setIdAttribute, setIdAttributeNode, setIdAttributeNS
 
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, asText, asXml, compareDocumentPosition, fireNodeAdded, fireNodeDeleted, getAllHtmlChildElements, getAncestors, getBaseURI, getByXPath, getChildNodes, getChildren, getDescendants, getEndColumnNumber, getEndLineNumber, getFeature, getFirstByXPath, getFirstChild, getHtmlElementDescendants, getIndex, getLastChild, getNextSibling, getNodeValue, getOwnerDocument, getPage, getParentNode, getPreviousSibling, getReadyState, getScriptObject, getStartColumnNumber, getStartLineNumber, getTextContent, getUserData, hasChildNodes, insertBefore, insertBefore, isAncestorOf, isAncestorOfAny, isBlock, isDefaultNamespace, isDisplayed, isEqualNode, isSameNode, isSupported, isTrimmedText, lookupNamespaceURI, lookupPrefix, mayBeDisplayed, normalize, notifyIncorrectness, onAddedToPage, onAllChildrenAddedToPage, printChildrenAsXml, 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
 

Field Detail

TAG_NAME

public static final String TAG_NAME
The HTML tag represented by this element.

See Also:
Constant Field Values
Method Detail

getWebRequestSettings

@Deprecated
public WebRequest getWebRequestSettings(SubmittableElement submitElement)
Deprecated. as of 2.8, please use getWebRequest(SubmittableElement) instead

INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Gets the settings for a submission of this form request settings necessary to submit this form.

Parameters:
submitElement - the element that caused the submit to occur
Returns:
the request settings

getWebRequest

public WebRequest getWebRequest(SubmittableElement submitElement)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Gets the request for a submission of this form with the specified SubmittableElement.

Parameters:
submitElement - the element that caused the submit to occur
Returns:
the request

reset

public Page reset()
Resets this form to its initial values, returning the page contained by this form's window after the reset. Note that the returned page may or may not be the same as the original page, based on JavaScript event handlers, etc.

Returns:
the page contained by this form's window after the reset

getInputsByName

public List<HtmlInput> getInputsByName(String name)
Returns all input elements which are members of this form and have the specified name.

Parameters:
name - the input name to search for
Returns:
all input elements which are members of this form and have the specified name

getInputByName

public final <I extends HtmlInput> I getInputByName(String name)
                                         throws ElementNotFoundException
Returns the first input element which is a member of this form and has the specified name.

Type Parameters:
I - the input type
Parameters:
name - the input name to search for
Returns:
the first input element which is a member of this form and has the specified name
Throws:
ElementNotFoundException - if there is not input in this form with the specified name

getSelectsByName

public List<HtmlSelect> getSelectsByName(String name)
Returns all the HtmlSelect elements in this form that have the specified name.

Parameters:
name - the name to search for
Returns:
all the HtmlSelect elements in this form that have the specified name

getSelectByName

public HtmlSelect getSelectByName(String name)
                           throws ElementNotFoundException
Returns the first HtmlSelect element in this form that has the specified name.

Parameters:
name - the name to search for
Returns:
the first HtmlSelect element in this form that has the specified name
Throws:
ElementNotFoundException - if this form does not contain a HtmlSelect element with the specified name

getButtonsByName

public List<HtmlButton> getButtonsByName(String name)
Returns all the HtmlButton elements in this form that have the specified name.

Parameters:
name - the name to search for
Returns:
all the HtmlButton elements in this form that have the specified name

getButtonByName

public HtmlButton getButtonByName(String name)
                           throws ElementNotFoundException
Returns the first HtmlButton element in this form that has the specified name.

Parameters:
name - the name to search for
Returns:
the first HtmlButton element in this form that has the specified name
Throws:
ElementNotFoundException - if this form does not contain a HtmlButton element with the specified name

getTextAreasByName

public List<HtmlTextArea> getTextAreasByName(String name)
Returns all the HtmlTextArea elements in this form that have the specified name.

Parameters:
name - the name to search for
Returns:
all the HtmlTextArea elements in this form that have the specified name

getTextAreaByName

public HtmlTextArea getTextAreaByName(String name)
                               throws ElementNotFoundException
Returns the first HtmlTextArea element in this form that has the specified name.

Parameters:
name - the name to search for
Returns:
the first HtmlTextArea element in this form that has the specified name
Throws:
ElementNotFoundException - if this form does not contain a HtmlTextArea element with the specified name

getRadioButtonsByName

public List<HtmlRadioButtonInput> getRadioButtonsByName(String name)
Returns all the HtmlRadioButtonInput elements in this form that have the specified name.

Parameters:
name - the name to search for
Returns:
all the HtmlRadioButtonInput elements in this form that have the specified name

getCheckedRadioButton

public HtmlRadioButtonInput getCheckedRadioButton(String name)
Returns the first checked radio button with the specified name. If none of the radio buttons by that name are checked, this method returns null.

Parameters:
name - the name of the radio button
Returns:
the first checked radio button with the specified name

getActionAttribute

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

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

setActionAttribute

public final void setActionAttribute(String action)
Sets the value of the attribute "action". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Parameters:
action - the value of the attribute "action"

getMethodAttribute

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

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

setMethodAttribute

public final void setMethodAttribute(String method)
Sets the value of the attribute "method". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Parameters:
method - the value of the attribute "method"

getNameAttribute

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

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

setNameAttribute

public final void setNameAttribute(String name)
Sets the value of the attribute "name". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Parameters:
name - the value of the attribute "name"

getEnctypeAttribute

public final String getEnctypeAttribute()
Returns the value of the attribute "enctype". Refer to the HTML 4.01 documentation for details on the use of this attribute. "Enctype" is the encoding type used when submitting a form back to the server.

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

setEnctypeAttribute

public final void setEnctypeAttribute(String encoding)
Sets the value of the attribute "enctype". Refer to the HTML 4.01 documentation for details on the use of this attribute. "Enctype" is the encoding type used when submitting a form back to the server.

Parameters:
encoding - the value of the attribute "enctype"

getOnSubmitAttribute

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

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

getOnResetAttribute

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

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

getAcceptAttribute

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

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

getAcceptCharsetAttribute

public final String getAcceptCharsetAttribute()
Returns the value of the attribute "accept-charset". Refer to the HTML 4.01 documentation for details on the use of this attribute.

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

getTargetAttribute

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

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

setTargetAttribute

public final void setTargetAttribute(String target)
Sets the value of the attribute "target". Refer to the HTML 4.01 documentation for details on the use of this attribute.

Parameters:
target - the value of the attribute "target"

getInputByValue

public <I extends HtmlInput> I getInputByValue(String value)
                                    throws ElementNotFoundException
Returns the first input in this form with the specified value.

Type Parameters:
I - the input type
Parameters:
value - the value to search for
Returns:
the first input in this form with the specified value
Throws:
ElementNotFoundException - if this form does not contain any inputs with the specified value

getInputsByValue

public List<HtmlInput> getInputsByValue(String value)
Returns all the inputs in this form with the specified value.

Parameters:
value - the value to search for
Returns:
all the inputs in this form with the specified value

getLostChildren

public List<HtmlElement> getLostChildren()
Gets the form elements that may be submitted but that don't belong to the form's children in the DOM due to incorrect HTML code.

Returns:
the elements

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


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