Class Button
The button element represents a clickable button that can be used to submit forms, trigger actions, or perform other interactive functions. Unlike input elements, buttons can contain rich content including text, images, and other HTML elements.
Examples:
The following convenience methods are provided for constructing instances of this bean:
See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionButton()Creates an emptyButtonelement.Creates aButtonelement with the specifiedtype(String)attribute.Creates aButtonelement with the specifiedtype(String)attribute andHtmlElementMixed.children(Object[])nodes. -
Method Summary
Modifier and TypeMethodDescriptionautofocus attribute.disabled attribute.form attribute.formaction(String value) formaction attribute.formenctype(String value) formenctype attribute.formmethod(String value) formmethod attribute.formnovalidate(String value) formnovalidate attribute.formtarget(String value) formtarget attribute.menu attribute.name attribute.type attribute.value 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
-
Button
public Button()Creates an emptyButtonelement. -
Button
Creates aButtonelement with the specifiedtype(String)attribute.- Parameters:
type- Thetype(String)attribute. Can benull to unset the attribute.
-
Button
Creates aButtonelement with the specifiedtype(String)attribute andHtmlElementMixed.children(Object[])nodes.- Parameters:
type- Thetype(String)attribute. Can benull to unset the attribute.children- TheHtmlElementMixed.children(Object[])nodes. Must not benull .
-
-
Method Details
-
autofocus
autofocus attribute.Automatically focus the form control when the page is loaded.
-
disabled
disabled attribute.Whether the form control is disabled.
This attribute uses deminimized values:
false - Attribute is not addedtrue - Attribute is added as"disabled" - Other values - Passed through as-is
-
form
form attribute.Associates the button with a form element by specifying the form's ID. This allows the button to be placed outside the form element while still being part of the form submission.
The value should match the ID of a form element in the same document.
- Parameters:
value- The ID of the form element to associate with this button. Can benull to unset the attribute.- Returns:
- This object.
-
formaction
formaction attribute.Specifies the URL where the form data will be submitted when this button is clicked. Overrides the form's action attribute.
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 URL where the form data will be submitted. Can benull , in which case the attribute is stored with anull value (not removed).- Returns:
- This object.
-
formenctype
formenctype attribute.Specifies how form data should be encoded when submitted. Overrides the form's enctype attribute.
Possible values:
"application/x-www-form-urlencoded" - Default encoding (default)"multipart/form-data" - For file uploads"text/plain" - Plain text encoding
- Parameters:
value- The encoding type for form submission. Can benull to unset the attribute.- Returns:
- This object.
-
formmethod
formmethod attribute.Specifies the HTTP method to use for form submission. Overrides the form's method attribute.
Possible values:
"get" - Form data is sent as URL parameters"post" - Form data is sent in the request body (default)"dialog" - Used for forms within dialog elements
- Parameters:
value- The HTTP method for form submission. Can benull to unset the attribute.- Returns:
- This object.
-
formnovalidate
formnovalidate attribute.Specifies that form validation should be bypassed when this button submits the form. Overrides the form's novalidate attribute.
This attribute uses deminimized values:
false - Form validation is performed (default)true - Form validation is bypassed- Other values - Passed through as-is
- Parameters:
value- Whether to bypass form validation. Can benull to unset the attribute.- Returns:
- This object.
-
formtarget
formtarget attribute.Specifies where to display the form response after submission. Overrides the form's target attribute.
Common values:
"_blank" - Open in a new window/tab"_self" - Open in the same frame (default)"_parent" - Open in the parent frame"_top" - Open in the full body of the window"framename" - Open in a named frame
- Parameters:
value- Where to display the form response. Can benull to unset the attribute.- Returns:
- This object.
-
name
name attribute.Specifies the name of the button. This name is used when the form is submitted and can be used to access the element via the form.elements API.
The name should be unique within the form and should not contain spaces or special characters.
- Parameters:
value- The name of the button for submission and API access. Can benull to unset the attribute.- Returns:
- This object.
-
type
type attribute.Specifies the type of button and its behavior when clicked.
Possible values:
"submit" - Submits the form (default)"reset" - Resets the form to its initial state"button" - Generic button with no default behavior
- Parameters:
value- The type of button and its behavior. Can benull to unset the attribute.- Returns:
- This object.
-
value
value attribute.Value to be used for form submission.
-