public class HtmlForm extends HtmlElement
HtmlElement.DisplayStyleDomElement.ChildElementsIteratorDomNode.ChildIterator, DomNode.DescendantDomElementsIterator, DomNode.DescendantDomNodesIterator, DomNode.DescendantHtmlElementsIterator| Modifier and Type | Field and Description |
|---|---|
static String |
ATTRIBUTE_FORMNOVALIDATE
The "formnovalidate" attribute name.
|
static String |
TAG_NAME
The HTML tag represented by this element.
|
ATTRIBUTE_CHECKED, ATTRIBUTE_HIDDEN, ATTRIBUTE_REQUIRED, TAB_INDEX_OUT_OF_BOUNDSATTRIBUTE_NOT_DEFINED, ATTRIBUTE_VALUE_EMPTY, ID_ATTRIBUTE, NAME_ATTRIBUTE, SRC_ATTRIBUTE, TYPE_ATTRIBUTE, VALUE_ATTRIBUTEPROPERTY_ELEMENT, READY_STATE_COMPLETE, READY_STATE_INTERACTIVE, READY_STATE_LOADED, READY_STATE_LOADING, READY_STATE_UNINITIALIZEDATTRIBUTE_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| Modifier and Type | Method and Description |
|---|---|
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.
|
List<HtmlElement> |
getElements(Predicate<HtmlElement> filter) |
List<HtmlElement> |
getElementsJS()
This is the backend for the getElements() javascript function of the form.
|
String |
getEnctypeAttribute()
Returns the value of the attribute
enctype. |
List<HtmlElement> |
getFormElements() |
<I extends HtmlInput> |
getInputByName(String name)
Returns the first input element which is a member of this form and has the specified name.
|
<I extends HtmlInput> |
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.
|
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<NameValuePair> |
getParameterListForSubmit(SubmittableElement submitElement)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
List<HtmlRadioButtonInput> |
getRadioButtonsByName(String name)
Returns all the
HtmlRadioButtonInput elements in this form that have the specified name. |
String |
getRelAttribute()
Returns the value of the attribute
rel. |
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.
|
protected boolean |
isEmptyXmlTagExpanded()
Browsers have problems with self closing form tags.
|
boolean |
isNoValidate() |
boolean |
isValid()
Returns whether this element satisfies all form validation constraints set.
|
protected void |
preventDefault()
This method is called if the current fired event is canceled by
preventDefault(). |
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 |
setNoValidate(boolean noValidate)
Sets the value of the attribute
novalidate. |
void |
setTargetAttribute(String target)
Sets the value of the attribute
target. |
void |
submit(SubmittableElement submitElement)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
acceptChar, addHtmlAttributeChangeListener, appendChildIfNoneExists, checkChildHierarchy, cloneNode, detach, doType, doType, fireHtmlAttributeAdded, fireHtmlAttributeRemoved, fireHtmlAttributeReplaced, getCanonicalXPath, getDefaultStyleDisplay, getElementsByAttribute, getEnclosingElement, getEnclosingForm, getEnclosingFormOrDie, getHidden, getLangAttribute, getNodeName, getOffsetLeft, getOffsetParentInternal, getOffsetTop, getOnClickAttribute, getOnDblClickAttribute, getOneHtmlElementByAttribute, getOnKeyDownAttribute, getOnKeyPressAttribute, getOnKeyUpAttribute, getOnMouseDownAttribute, getOnMouseMoveAttribute, getOnMouseOutAttribute, getOnMouseOverAttribute, getOnMouseUpAttribute, getPosX, getPosY, getSrcAttributeNormalized, getTabIndex, getTextDirectionAttribute, getXmlLangAttribute, handles, hasEventHandlers, isAltPressed, isAttributeCaseSensitive, isCtrlPressed, isDisplayed, isHidden, isOptional, isRequired, isRequiredSupported, isShiftPressed, isSubmittableByEnter, notifyAttributeChangeListeners, removeAttribute, removeChild, removeHtmlAttributeChangeListener, setAttributeNode, setAttributeNS, setHidden, setHidden, setOwningForm, setRequired, type, type, type, type, typeDoneblur, click, click, click, click, click, dblClick, dblClick, doClickFireChangeEvent, doClickFireClickEvent, doClickStateUpdate, fireEvent, fireEvent, focus, getAttribute, getAttributeDirect, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getAttributesMap, getChildElementCount, getChildElements, getElementsByTagName, getElementsByTagNameNS, getEventTargetElement, getFirstElementChild, getId, getLastElementChild, getNodeType, getSchemaTypeInfo, getStaticElementsByTagName, getStyleElement, getStyleElementCaseInSensitive, getStyleMap, getTagName, hasAttribute, hasAttributeNS, hasAttributes, isDisabledElementAndDisabled, isMouseOver, isStateUpdateFirst, matches, mouseDown, mouseDown, mouseMove, mouseMove, mouseOut, mouseOut, mouseOver, mouseOver, mouseUp, mouseUp, printOpeningTagContentAsXml, printXml, propagateClickStateUpdateToParent, removeAttributeNode, removeAttributeNS, removeFocus, removeStyleAttribute, replaceStyleAttribute, rightClick, rightClick, setAttribute, setAttributeNodeNS, setAttributeNS, setDefaults, setId, setIdAttribute, setIdAttributeNode, setIdAttributeNS, setInnerHtml, setNodeValue, toString, writeStyleToElementgetLocalName, getLowercaseName, getNamespaceURI, getPrefix, getQualifiedName, processImportNode, setPrefixaddCharacterDataChangeListener, addDomChangeListener, appendChild, asNormalizedText, asXml, basicRemove, closest, compareDocumentPosition, fireCharacterDataChanged, fireNodeAdded, fireNodeDeleted, getAncestors, getBaseURI, getByXPath, getByXPath, getChildNodes, getChildren, getDescendants, getDomElementDescendants, getEndColumnNumber, getEndLineNumber, getFeature, getFirstByXPath, getFirstByXPath, getFirstChild, getHtmlElementDescendants, getHtmlPageOrNull, getIndex, getLastChild, getNextElementSibling, getNextSibling, getNodeValue, getOwnerDocument, getPage, getParentNode, getPreviousElementSibling, getPreviousSibling, getReadyState, getScriptableObject, getSelectorList, getStartColumnNumber, getStartLineNumber, getTextContent, getUserData, getVisibleText, hasChildNodes, hasFeature, insertBefore, insertBefore, isAncestorOf, isAncestorOfAny, isAttachedToPage, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, mayBeDisplayed, normalize, notifyIncorrectness, onAddedToDocumentFragment, onAddedToPage, onAllChildrenAddedToPage, parseHtmlSnippet, printChildrenAsXml, querySelector, querySelectorAll, quietlyRemoveAndMoveChildrenTo, remove, removeAllChildren, removeCharacterDataChangeListener, removeChild, removeDomChangeListener, replace, replaceChild, setEndLocation, setParentNode, setReadyState, setScriptableObject, setStartLocation, setTextContent, setUserDataclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitappendChild, 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, setPrefix, setTextContent, setUserDatapublic static final String TAG_NAME
public static final String ATTRIBUTE_FORMNOVALIDATE
public void submit(SubmittableElement submitElement)
Submits this form to the server. If submitElement is null, then
the submission is treated as if it was triggered by JavaScript, and the onsubmit
handler will not be executed.
IMPORTANT: Using this method directly is not the preferred way of submitting forms.
Most consumers should emulate the user's actions instead, probably by using something like
DomElement.click() or DomElement.dblClick().
submitElement - the element that caused the submit to occurpublic WebRequest getWebRequest(SubmittableElement submitElement)
submitElement - the element that caused the submit to occurpublic List<NameValuePair> getParameterListForSubmit(SubmittableElement submitElement)
NameValuePairs that represent the data that will be
sent to the server when this form is submitted. This is primarily intended to aid
debugging.submitElement - the element used to submit the form, or null if the
form was submitted by JavaScriptNameValuePairs that represent that data that will be sent
to the server when this form is submittedpublic Page reset()
public boolean isValid()
isValid in class HtmlElementpublic List<HtmlInput> getInputsByName(String name)
name - the input name to search forpublic List<HtmlElement> getFormElements()
public List<HtmlElement> getElementsJS()
public List<HtmlElement> getElements(Predicate<HtmlElement> filter)
filter - a predicate to filter the elementpublic final <I extends HtmlInput> I getInputByName(String name) throws ElementNotFoundException
I - the input typename - the input name to search forElementNotFoundException - if there is no input in this form with the specified namepublic List<HtmlSelect> getSelectsByName(String name)
HtmlSelect elements in this form that have the specified name.name - the name to search forHtmlSelect elements in this form that have the specified namepublic HtmlSelect getSelectByName(String name) throws ElementNotFoundException
HtmlSelect element in this form that has the specified name.name - the name to search forHtmlSelect element in this form that has the specified nameElementNotFoundException - if this form does not contain a HtmlSelect
element with the specified namepublic List<HtmlButton> getButtonsByName(String name)
HtmlButton elements in this form that have the specified name.name - the name to search forHtmlButton elements in this form that have the specified namepublic HtmlButton getButtonByName(String name) throws ElementNotFoundException
HtmlButton element in this form that has the specified name.name - the name to search forHtmlButton element in this form that has the specified nameElementNotFoundException - if this form does not contain a HtmlButton
element with the specified namepublic List<HtmlTextArea> getTextAreasByName(String name)
HtmlTextArea elements in this form that have the specified name.name - the name to search forHtmlTextArea elements in this form that have the specified namepublic HtmlTextArea getTextAreaByName(String name) throws ElementNotFoundException
HtmlTextArea element in this form that has the specified name.name - the name to search forHtmlTextArea element in this form that has the specified nameElementNotFoundException - if this form does not contain a HtmlTextArea
element with the specified namepublic List<HtmlRadioButtonInput> getRadioButtonsByName(String name)
HtmlRadioButtonInput elements in this form that have the specified name.name - the name to search forHtmlRadioButtonInput elements in this form that have the specified namepublic HtmlRadioButtonInput getCheckedRadioButton(String name)
null.name - the name of the radio buttonpublic final String getActionAttribute()
action. Refer to the HTML 4.01 documentation for
details on the use of this attribute.action or an empty string if that attribute isn't definedpublic final void setActionAttribute(String action)
action. Refer to the HTML 4.01 documentation for
details on the use of this attribute.action - the value of the attribute actionpublic final String getMethodAttribute()
method. Refer to the HTML 4.01 documentation for
details on the use of this attribute.method or an empty string if that attribute isn't definedpublic final void setMethodAttribute(String method)
method. Refer to the HTML 4.01 documentation for
details on the use of this attribute.method - the value of the attribute methodpublic final String getNameAttribute()
name. Refer to the HTML 4.01 documentation for
details on the use of this attribute.name or an empty string if that attribute isn't definedpublic final void setNameAttribute(String name)
name. Refer to the HTML 4.01 documentation for
details on the use of this attribute.name - the value of the attribute namepublic final String getEnctypeAttribute()
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.enctype or an empty string if that attribute isn't definedpublic final void setEnctypeAttribute(String encoding)
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.encoding - the value of the attribute enctypepublic final String getOnSubmitAttribute()
onsubmit. Refer to the HTML 4.01 documentation for
details on the use of this attribute.onsubmit or an empty string if that attribute isn't definedpublic final String getOnResetAttribute()
onreset. Refer to the HTML 4.01 documentation for
details on the use of this attribute.onreset or an empty string if that attribute isn't definedpublic final String getAcceptAttribute()
accept. Refer to the HTML 4.01 documentation for
details on the use of this attribute.accept or an empty string if that attribute isn't definedpublic final String getAcceptCharsetAttribute()
accept-charset. Refer to the
HTML 4.01 documentation for details on the use of this attribute.accept-charset or an empty string if that attribute isn't definedpublic final String getTargetAttribute()
target. Refer to the HTML 4.01 documentation for
details on the use of this attribute.target or an empty string if that attribute isn't definedpublic final void setTargetAttribute(String target)
target. Refer to the HTML 4.01 documentation for
details on the use of this attribute.target - the value of the attribute targetpublic final String getRelAttribute()
rel. Refer to the
HTML 4.01
documentation for details on the use of this attribute.rel or an empty string if that attribute isn't definedpublic <I extends HtmlInput> I getInputByValue(String value) throws ElementNotFoundException
I - the input typevalue - the value to search forElementNotFoundException - if this form does not contain any inputs with the specified valuepublic List<HtmlInput> getInputsByValue(String value)
value - the value to search forprotected void preventDefault()
preventDefault().
The default implementation does nothing.
preventDefault in class DomElementprotected boolean isEmptyXmlTagExpanded()
isEmptyXmlTagExpanded in class DomElementfalse by defaultpublic final boolean isNoValidate()
novalidate or an empty string if that attribute isn't definedpublic final void setNoValidate(boolean noValidate)
novalidate.noValidate - the value of the attribute novalidateCopyright © 2002–2025 Gargoyle Software Inc.. All rights reserved.