org.jsoup.nodes
Class FormElement

java.lang.Object
  extended by org.jsoup.nodes.Node
      extended by org.jsoup.nodes.Element
          extended by org.jsoup.nodes.FormElement
All Implemented Interfaces:
Cloneable

public class FormElement
extends Element

A HTML Form Element provides ready access to the form fields/controls that are associated with it. It also allows a form to easily be submitted.


Constructor Summary
FormElement(Tag tag, String baseUri, Attributes attributes)
          Create a new, standalone form element.
 
Method Summary
 FormElement addElement(Element element)
          Add a form control element to this form.
 Elements elements()
          Get the list of form control elements associated with this form.
 boolean equals(Object o)
           
 List<Connection.KeyVal> formData()
          Get the data that this form submits.
 Connection submit()
          Prepare to submit this form.
 
Methods inherited from class org.jsoup.nodes.Element
addClass, after, after, append, appendChild, appendElement, appendText, attr, before, before, child, children, className, classNames, classNames, clone, cssSelector, data, dataNodes, dataset, elementSiblingIndex, empty, firstElementSibling, getAllElements, getElementById, getElementsByAttribute, getElementsByAttributeStarting, getElementsByAttributeValue, getElementsByAttributeValueContaining, getElementsByAttributeValueEnding, getElementsByAttributeValueMatching, getElementsByAttributeValueMatching, getElementsByAttributeValueNot, getElementsByAttributeValueStarting, getElementsByClass, getElementsByIndexEquals, getElementsByIndexGreaterThan, getElementsByIndexLessThan, getElementsByTag, getElementsContainingOwnText, getElementsContainingText, getElementsMatchingOwnText, getElementsMatchingOwnText, getElementsMatchingText, getElementsMatchingText, hasClass, hashCode, hasText, html, html, id, insertChildren, isBlock, lastElementSibling, nextElementSibling, nodeName, ownText, parent, parents, prepend, prependChild, prependElement, prependText, previousElementSibling, removeClass, select, siblingElements, tag, tagName, tagName, text, text, textNodes, toggleClass, toString, val, val, wrap
 
Methods inherited from class org.jsoup.nodes.Node
absUrl, addChildren, addChildren, attr, attributes, baseUri, childNode, childNodes, childNodesAsArray, childNodesCopy, childNodeSize, doClone, hasAttr, indent, nextSibling, outerHtml, outerHtml, ownerDocument, parentNode, previousSibling, remove, removeAttr, removeChild, replaceChild, replaceWith, setBaseUri, setParentNode, setSiblingIndex, siblingIndex, siblingNodes, traverse, unwrap
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FormElement

public FormElement(Tag tag,
                   String baseUri,
                   Attributes attributes)
Create a new, standalone form element.

Parameters:
tag - tag of this element
baseUri - the base URI
attributes - initial attributes
Method Detail

elements

public Elements elements()
Get the list of form control elements associated with this form.

Returns:
form controls associated with this element.

addElement

public FormElement addElement(Element element)
Add a form control element to this form.

Parameters:
element - form control to add
Returns:
this form element, for chaining

submit

public Connection submit()
Prepare to submit this form. A Connection object is created with the request set up from the form values. You can then set up other options (like user-agent, timeout, cookies), then execute it.

Returns:
a connection prepared from the values of this form.
Throws:
IllegalArgumentException - if the form's absolute action URL cannot be determined. Make sure you pass the document's base URI when parsing.

formData

public List<Connection.KeyVal> formData()
Get the data that this form submits. The returned list is a copy of the data, and changes to the contents of the list will not be reflected in the DOM.

Returns:
a list of key vals

equals

public boolean equals(Object o)
Overrides:
equals in class Element


Copyright © 2009-2014 Jonathan Hedley. All Rights Reserved.