Package org.jsoup.nodes
Class FormElement
- java.lang.Object
-
- org.jsoup.nodes.Node
-
- org.jsoup.nodes.Element
-
- org.jsoup.nodes.FormElement
-
- All Implemented Interfaces:
java.lang.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.
-
-
Field Summary
Fields Modifier and Type Field Description private Elements
elements
-
Fields inherited from class org.jsoup.nodes.Element
childNodes
-
Fields inherited from class org.jsoup.nodes.Node
EmptyString, parentNode, siblingIndex
-
-
Constructor Summary
Constructors Constructor Description FormElement(Tag tag, java.lang.String baseUri, Attributes attributes)
Create a new, standalone form element.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.java.util.List<Connection.KeyVal>
formData()
Get the data that this form submits.protected void
removeChild(Node out)
Connection
submit()
Prepare to submit this form.-
Methods inherited from class org.jsoup.nodes.Element
addClass, after, after, append, appendChild, appendElement, appendText, appendTo, attr, attr, attributes, baseUri, before, before, child, childNodeSize, children, className, classNames, classNames, clone, cssSelector, data, dataNodes, dataset, doClone, doSetBaseUri, elementSiblingIndex, empty, ensureChildNodes, firstElementSibling, getAllElements, getElementById, getElementsByAttribute, getElementsByAttributeStarting, getElementsByAttributeValue, getElementsByAttributeValueContaining, getElementsByAttributeValueEnding, getElementsByAttributeValueMatching, getElementsByAttributeValueMatching, getElementsByAttributeValueNot, getElementsByAttributeValueStarting, getElementsByClass, getElementsByIndexEquals, getElementsByIndexGreaterThan, getElementsByIndexLessThan, getElementsByTag, getElementsContainingOwnText, getElementsContainingText, getElementsMatchingOwnText, getElementsMatchingOwnText, getElementsMatchingText, getElementsMatchingText, hasAttributes, hasClass, hasText, html, html, html, id, insertChildren, insertChildren, is, is, isBlock, lastElementSibling, nextElementSibling, nextElementSiblings, nodelistChanged, nodeName, normalName, outerHtmlHead, outerHtmlTail, ownText, parent, parents, prepend, prependChild, prependElement, prependText, preserveWhitespace, previousElementSibling, previousElementSiblings, removeClass, select, selectFirst, shallowClone, siblingElements, tag, tagName, tagName, text, text, textNodes, toggleClass, val, val, wholeText, wrap
-
Methods inherited from class org.jsoup.nodes.Node
absUrl, addChildren, addChildren, attr, childNode, childNodes, childNodesAsArray, childNodesCopy, clearAttributes, equals, filter, hasAttr, hasParent, hasSameValue, indent, nextSibling, outerHtml, outerHtml, ownerDocument, parentNode, previousSibling, remove, removeAttr, reparentChild, replaceChild, replaceWith, root, setBaseUri, setParentNode, setSiblingIndex, siblingIndex, siblingNodes, toString, traverse, unwrap
-
-
-
-
Field Detail
-
elements
private final Elements elements
-
-
Constructor Detail
-
FormElement
public FormElement(Tag tag, java.lang.String baseUri, Attributes attributes)
Create a new, standalone form element.- Parameters:
tag
- tag of this elementbaseUri
- the base URIattributes
- 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
-
removeChild
protected void removeChild(Node out)
- Overrides:
removeChild
in classNode
-
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:
java.lang.IllegalArgumentException
- if the form's absolute action URL cannot be determined. Make sure you pass the document's base URI when parsing.
-
formData
public java.util.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
-
-