Class Form
The form element represents a document section containing interactive controls for submitting information to a web server. It groups form controls together and defines how the data should be submitted, including the target URL, HTTP method, and encoding type.
Examples:
The following convenience methods are provided for constructing instances of this bean:
See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionacceptcharset(String value) accept-charset attribute.action attribute.autocomplete(String value) autocomplete attribute.enctype attribute.method attribute.name attribute.novalidate(Boolean value) novalidate attribute.target attribute.Methods inherited from class org.apache.juneau.bean.html5.HtmlElementMixed
child, children, getChild, getChild, getChild, getChildren, setChildrenMethods inherited from class org.apache.juneau.bean.html5.HtmlElement
accesskey, attr, attrUri, class_, contenteditable, deminimize, dir, getAttr, getAttr, getAttrs, hidden, id, lang, onabort, onblur, oncancel, oncanplay, oncanplaythrough, onchange, onclick, oncuechange, ondblclick, ondurationchange, onemptied, onended, onerror, onfocus, oninput, oninvalid, onkeydown, onkeypress, onkeyup, onload, onloadeddata, onloadedmetadata, onloadstart, onmousedown, onmouseenter, onmouseleave, onmousemove, onmouseout, onmouseover, onmouseup, onmousewheel, onpause, onplay, onplaying, onprogress, onratechange, onreset, onresize, onscroll, onseeked, onseeking, onselect, onshow, onstalled, onsubmit, onsuspend, ontimeupdate, ontoggle, onvolumechange, onwaiting, self, setAttrs, spellcheck, style, tabindex, title, toString, translate
-
Constructor Details
-
Form
public Form()Creates an emptyFormelement. -
Form
Creates aFormelement with the specifiedaction(String)attribute.- Parameters:
action- Theaction(String)attribute. Can benull , in which case the attribute is stored with anull value (not removed).
-
Form
Creates anFormelement with the specifiedaction(String)attribute and child nodes.- Parameters:
action- Theaction(String)attribute. Can benull , in which case the attribute is stored with anull value (not removed).children- The child nodes. Must not benull .
-
-
Method Details
-
acceptcharset
accept-charset attribute.Specifies the character encodings that are accepted for form submission. Multiple encodings can be specified as a space-separated list.
Common values:
"UTF-8" - Unicode UTF-8 encoding (default)"ISO-8859-1" - Latin-1 encoding"UTF-8 ISO-8859-1" - Multiple encodings
- Parameters:
value- The character encodings accepted for form submission. Can benull to unset the attribute.- Returns:
- This object.
-
action
action attribute.URL to use for form submission.
The value can be of any of the following types:
URI,URL,String. Strings must be valid URIs.URIs defined by
UriResolvercan be used for values.- Parameters:
value- The new value for this attribute. Can benull , in which case the attribute is stored with anull value (not removed).- Returns:
- This object.
-
autocomplete
autocomplete attribute.Sets the default autocomplete behavior for all form controls within this form. Individual controls can override this setting.
Possible values:
"on" - Allow autocomplete (default)"off" - Disable autocomplete
- Parameters:
value- The default autocomplete behavior for form controls. Can benull to unset the attribute.- Returns:
- This object.
-
enctype
enctype attribute.Specifies how form data should be encoded when submitted to the server.
Possible values:
"application/x-www-form-urlencoded" - Default encoding (default)"multipart/form-data" - Used for file uploads"text/plain" - Plain text encoding
- Parameters:
value- The encoding type for form data submission. Can benull to unset the attribute.- Returns:
- This object.
-
method
method attribute.Specifies the HTTP method to use when submitting the form.
Possible values:
"get" - Form data is sent as URL parameters (default)"post" - Form data is sent in the request body"dialog" - Used for forms within dialog elements
- Parameters:
value- The HTTP method for form submission. Can benull to unset the attribute.- Returns:
- This object.
-
name
name attribute.Specifies the name of the form. This name can be used to access the form via the document.forms API and for form submission.
The name should be unique within the document and should not contain spaces or special characters.
- Parameters:
value- The name of the form for API access and submission. Can benull to unset the attribute.- Returns:
- This object.
-
novalidate
novalidate attribute.Disables form validation, allowing the form to be submitted even if validation fails.
- Parameters:
value- Iftrue , disables form validation. Can benull to unset the attribute.- Returns:
- This object.
-
target
target attribute.Specifies where to display the response after form submission.
Possible values:
"_self" - Load in the same frame (default)"_blank" - Load in a new window or tab"_parent" - Load in the parent frame"_top" - Load in the full body of the window- Frame name - Load in the named frame
- Parameters:
value- Where to display the form submission response. Can benull to unset the attribute.- Returns:
- This object.
-