Class HtmlElement<SELF extends HtmlElement<SELF>>
- Type Parameters:
SELF- The self type for fluent setters.
- Direct Known Subclasses:
HtmlElementContainer,HtmlElementMixed,HtmlElementRawText,HtmlElementText,HtmlElementVoid
These are beans that when serialized using HtmlSerializer generate valid HTML5 elements.
See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaccesskey attribute.Adds an arbitrary attribute to this element.Adds an arbitrary URI attribute to this element.class attribute.contenteditable(Object value) contenteditable attribute.protected Objectdeminimize(Object value, String attr) If the specified attribute is a boolean, it gets converted to the attribute name iftrue ornull iffalse .dir attribute.<T> TReturns the attribute with the specified name converted to the specified class type.Returns the attribute with the specified name.getAttrs()The attributes of this element.hidden attribute.id attribute.lang attribute.onabort attribute.onblur attribute.oncancel attribute.oncanplay attribute.oncanplaythrough(String value) oncanplaythrough attribute.onchange attribute.onclick attribute.oncuechange(String value) oncuechange attribute.ondblclick(String value) ondblclick attribute.ondurationchange(String value) ondurationchange attribute.onemptied attribute.onended attribute.onerror attribute.onfocus attribute.oninput attribute.oninvalid attribute.onkeydown attribute.onkeypress(String value) onkeypress attribute.onkeyup attribute.onload attribute.onloadeddata(String value) onloadeddata attribute.onloadedmetadata(String value) onloadedmetadata attribute.onloadstart(String value) onloadstart attribute.onmousedown(String value) onmousedown attribute.onmouseenter(String value) onmouseenter attribute.onmouseleave(String value) onmouseleave attribute.onmousemove(String value) onmousemove attribute.onmouseout(String value) onmouseout attribute.onmouseover(String value) onmouseover attribute.onmouseup attribute.onmousewheel(String value) onmousewheel attribute.onpause attribute.onplay attribute.onplaying attribute.onprogress(String value) onprogress attribute.onratechange(String value) onratechange attribute.onreset attribute.onresize attribute.onscroll attribute.onseeked attribute.onseeking attribute.onselect attribute.onshow attribute.onstalled attribute.onsubmit attribute.onsuspend attribute.ontimeupdate(String value) ontimeupdate attribute.ontoggle attribute.onvolumechange(String value) onvolumechange attribute.onwaiting attribute.protected final SELFself()Sets the attributes for this element.spellcheck(Object value) spellcheck attribute.style attribute.tabindex attribute.title attribute.toString()translate attribute.
-
Constructor Details
-
HtmlElement
public HtmlElement()
-
-
Method Details
-
self
-
class_
class attribute.Specifies one or more CSS class names for the element, separated by spaces. These classes can be used for styling and JavaScript selection.
- Parameters:
value- Space-separated CSS class names (e.g.,"btn btn-primary" ). Can benull to unset the attribute.- Returns:
- This object.
-
accesskey
accesskey attribute.Defines a keyboard shortcut to activate or focus an element. The value should be a single character that, when pressed with a modifier key (usually Alt), activates the element.
- Parameters:
value- The keyboard shortcut character (e.g.,"a" ,"1" ). Can benull to unset the attribute.- Returns:
- This object.
-
attr
Adds an arbitrary attribute to this element.- Parameters:
key- The attribute name.val- The attribute value. Can benull to remove the attribute.- Returns:
- This object.
-
attrUri
Adds an arbitrary URI attribute to this element.Same as
attr(String, Object), except if the value is a string that appears to be a URI (e.g."servlet:/xxx" ).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:
key- The attribute name.val- The attribute value. Can benull , in which case the attribute is added with anull value (unlikeattr(String, Object), the key is not removed).- Returns:
- This object.
-
contenteditable
contenteditable attribute.Indicates whether the element's content is editable by the user.
Possible values:
"true" or empty string - Element content is editable"false" - Element content is not editable"plaintext-only" - Element content is editable, but rich text formatting is disabled
- Parameters:
value- The editability state of the element. Can benull to unset the attribute.- Returns:
- This object.
-
dir
dir attribute.Specifies the text direction of the element's content.
Possible values:
"ltr" - Left-to-right text direction"rtl" - Right-to-left text direction"auto" - Browser determines direction based on content
- Parameters:
value- The text direction for the element. Can benull to unset the attribute.- Returns:
- This object.
-
getAttr
Returns the attribute with the specified name converted to the specified class type.- Type Parameters:
T- The class type to convert this class to.- Parameters:
type- The class type to convert this class to. SeeBasicConverterfor a list of supported conversion types.key- The attribute name.- Returns:
- The attribute value, or
null if the named attribute does not exist. - Throws:
InvalidConversionException- If the attribute value cannot be converted to the specified type.
-
getAttr
Returns the attribute with the specified name.- Parameters:
key- The attribute name.- Returns:
- The attribute value, or
null if the named attribute does not exist.
-
getAttrs
The attributes of this element.- Returns:
- The attributes of this element, or
null if no attributes are set.
-
id
id attribute.Specifies a unique identifier for the element. The ID must be unique within the document and can be used for CSS styling, JavaScript selection, and anchor links.
- Parameters:
value- A unique identifier for the element (e.g.,"header" ,"main-content" ). Can benull to unset the attribute.- Returns:
- This object.
-
lang
lang attribute.Specifies the primary language of the element's content using a language tag. This helps with accessibility, search engines, and browser features like spell checking.
- Parameters:
value- A language tag (e.g.,"en" ,"en-US" ,"es" ,"fr-CA" ). Can benull to unset the attribute.- Returns:
- This object.
-
onabort
onabort attribute.Event handler for when an operation is aborted (e.g., image loading is cancelled).
- Parameters:
value- JavaScript code to execute when the abort event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onblur
onblur attribute.Event handler for when the element loses focus.
Note:
If your HTML serializer is configured to use single quotes for attribute values, you should use double quotes in your JavaScript code, and vice versa. Otherwise, the quotes will be converted to HTML entities. For example:
- If using single quotes for attributes:
onblur( "validate(\"email\")" ) - If using double quotes for attributes:
onblur( "validate('email')" )
- Parameters:
value- JavaScript code to execute when the element loses focus. Can benull to unset the attribute.- Returns:
- This object.
- If using single quotes for attributes:
-
oncancel
oncancel attribute.Event handler for when a dialog is cancelled.
- Parameters:
value- JavaScript code to execute when the cancel event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
oncanplay
oncanplay attribute.Event handler for when the media can start playing (enough data has been buffered).
- Parameters:
value- JavaScript code to execute when the canplay event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
oncanplaythrough
oncanplaythrough attribute.Event handler for when the media can play through to the end without buffering.
- Parameters:
value- JavaScript code to execute when the canplaythrough event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onchange
onchange attribute.Event handler for when the value of a form element changes and loses focus.
Note:
If your HTML serializer is configured to use single quotes for attribute values, you should use double quotes in your JavaScript code, and vice versa. Otherwise, the quotes will be converted to HTML entities. For example:
- If using single quotes for attributes:
onchange( "validate(\"field\")" ) - If using double quotes for attributes:
onchange( "validate('field')" )
- Parameters:
value- JavaScript code to execute when the change event occurs. Can benull to unset the attribute.- Returns:
- This object.
- If using single quotes for attributes:
-
onclick
onclick attribute.Event handler for when the element is clicked.
Note:
If your HTML serializer is configured to use single quotes for attribute values, you should use double quotes in your JavaScript code, and vice versa. Otherwise, the quotes will be converted to HTML entities. For example:
- If using single quotes for attributes:
onclick( "alert(\"Hello\")" ) - If using double quotes for attributes:
onclick( "alert('Hello')" )
- Parameters:
value- JavaScript code to execute when the click event occurs. Can benull to unset the attribute.- Returns:
- This object.
- If using single quotes for attributes:
-
oncuechange
oncuechange attribute.Event handler for when a text track cue changes.
- Parameters:
value- JavaScript code to execute when the cuechange event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
ondblclick
ondblclick attribute.Event handler for when the element is double-clicked.
- Parameters:
value- JavaScript code to execute when the dblclick event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
ondurationchange
ondurationchange attribute.Event handler for when the duration of the media changes.
- Parameters:
value- JavaScript code to execute when the durationchange event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onemptied
onemptied attribute.Event handler for when the media element becomes empty (e.g., network error).
- Parameters:
value- JavaScript code to execute when the emptied event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onended
onended attribute.Event handler for when the media playback reaches the end.
- Parameters:
value- JavaScript code to execute when the ended event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onerror
onerror attribute.Event handler for when an error occurs (e.g., failed resource loading).
- Parameters:
value- JavaScript code to execute when the error event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onfocus
onfocus attribute.Event handler for when the element receives focus.
Note:
If your HTML serializer is configured to use single quotes for attribute values, you should use double quotes in your JavaScript code, and vice versa. Otherwise, the quotes will be converted to HTML entities. For example:
- If using single quotes for attributes:
onfocus( "highlight(\"field\")" ) - If using double quotes for attributes:
onfocus( "highlight('field')" )
- Parameters:
value- JavaScript code to execute when the focus event occurs. Can benull to unset the attribute.- Returns:
- This object.
- If using single quotes for attributes:
-
oninput
oninput attribute.Event handler for when the value of an input element changes (fires on every keystroke).
- Parameters:
value- JavaScript code to execute when the input event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
oninvalid
oninvalid attribute.Event handler for when form validation fails.
- Parameters:
value- JavaScript code to execute when the invalid event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onkeydown
onkeydown attribute.Event handler for when a key is pressed down.
- Parameters:
value- JavaScript code to execute when the keydown event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onkeypress
onkeypress attribute.Event handler for when a key is pressed (deprecated, use onkeydown instead).
- Parameters:
value- JavaScript code to execute when the keypress event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onkeyup
onkeyup attribute.Event handler for when a key is released.
- Parameters:
value- JavaScript code to execute when the keyup event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onload
onload attribute.Event handler for when the element and its resources have finished loading.
Note:
If your HTML serializer is configured to use single quotes for attribute values, you should use double quotes in your JavaScript code, and vice versa. Otherwise, the quotes will be converted to HTML entities. For example:
- If using single quotes for attributes:
onload( "init(\"config\")" ) - If using double quotes for attributes:
onload( "init('config')" )
- Parameters:
value- JavaScript code to execute when the load event occurs. Can benull to unset the attribute.- Returns:
- This object.
- If using single quotes for attributes:
-
onloadeddata
onloadeddata attribute.Event handler for when the first frame of media has finished loading.
- Parameters:
value- JavaScript code to execute when the loadeddata event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onloadedmetadata
onloadedmetadata attribute.Event handler for when metadata (duration, dimensions, etc.) has been loaded.
- Parameters:
value- JavaScript code to execute when the loadedmetadata event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onloadstart
onloadstart attribute.Event handler for when the browser starts loading the media.
- Parameters:
value- JavaScript code to execute when the loadstart event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onmousedown
onmousedown attribute.Event handler for when a mouse button is pressed down on the element.
- Parameters:
value- JavaScript code to execute when the mousedown event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onmouseenter
onmouseenter attribute.Event handler for when the mouse pointer enters the element (does not bubble).
- Parameters:
value- JavaScript code to execute when the mouseenter event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onmouseleave
onmouseleave attribute.Event handler for when the mouse pointer leaves the element (does not bubble).
- Parameters:
value- JavaScript code to execute when the mouseleave event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onmousemove
onmousemove attribute.Event handler for when the mouse pointer moves over the element.
- Parameters:
value- JavaScript code to execute when the mousemove event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onmouseout
onmouseout attribute.Event handler for when the mouse pointer moves out of the element (bubbles).
- Parameters:
value- JavaScript code to execute when the mouseout event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onmouseover
onmouseover attribute.Event handler for when the mouse pointer moves over the element (bubbles).
Note:
If your HTML serializer is configured to use single quotes for attribute values, you should use double quotes in your JavaScript code, and vice versa. Otherwise, the quotes will be converted to HTML entities. For example:
- If using single quotes for attributes:
onmouseover( "showTooltip(\"info\")" ) - If using double quotes for attributes:
onmouseover( "showTooltip('info')" )
- Parameters:
value- JavaScript code to execute when the mouseover event occurs. Can benull to unset the attribute.- Returns:
- This object.
- If using single quotes for attributes:
-
onmouseup
onmouseup attribute.Event handler for when a mouse button is released over the element.
- Parameters:
value- JavaScript code to execute when the mouseup event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onmousewheel
onmousewheel attribute.Event handler for when the mouse wheel is rotated over the element (deprecated, use onwheel).
- Parameters:
value- JavaScript code to execute when the mousewheel event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onpause
onpause attribute.Event handler for when media playback is paused.
- Parameters:
value- JavaScript code to execute when the pause event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onplay
onplay attribute.Event handler for when media playback starts.
- Parameters:
value- JavaScript code to execute when the play event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onplaying
onplaying attribute.Event handler for when media playback starts after being paused or delayed.
- Parameters:
value- JavaScript code to execute when the playing event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onprogress
onprogress attribute.Event handler for when the browser is downloading media data.
- Parameters:
value- JavaScript code to execute when the progress event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onratechange
onratechange attribute.Event handler for when the playback rate of media changes.
- Parameters:
value- JavaScript code to execute when the ratechange event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onreset
onreset attribute.Event handler for when a form is reset.
- Parameters:
value- JavaScript code to execute when the reset event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onresize
onresize attribute.Event handler for when the element is resized.
- Parameters:
value- JavaScript code to execute when the resize event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onscroll
onscroll attribute.Event handler for when the element's scrollbar is scrolled.
- Parameters:
value- JavaScript code to execute when the scroll event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onseeked
onseeked attribute.Event handler for when a seek operation completes.
- Parameters:
value- JavaScript code to execute when the seeked event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onseeking
onseeking attribute.Event handler for when a seek operation begins.
- Parameters:
value- JavaScript code to execute when the seeking event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onselect
onselect attribute.Event handler for when text is selected in the element.
- Parameters:
value- JavaScript code to execute when the select event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onshow
onshow attribute.Event handler for when a context menu is shown.
- Parameters:
value- JavaScript code to execute when the show event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onstalled
onstalled attribute.Event handler for when media loading is stalled.
- Parameters:
value- JavaScript code to execute when the stalled event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onsubmit
onsubmit attribute.Event handler for when a form is submitted.
Note:
If your HTML serializer is configured to use single quotes for attribute values, you should use double quotes in your JavaScript code, and vice versa. Otherwise, the quotes will be converted to HTML entities. For example:
- If using single quotes for attributes:
onsubmit( "return validate(\"form\")" ) - If using double quotes for attributes:
onsubmit( "return validate('form')" )
- Parameters:
value- JavaScript code to execute when the submit event occurs. Can benull to unset the attribute.- Returns:
- This object.
- If using single quotes for attributes:
-
onsuspend
onsuspend attribute.Event handler for when media loading is suspended.
- Parameters:
value- JavaScript code to execute when the suspend event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
ontimeupdate
ontimeupdate attribute.Event handler for when the current playback position changes.
- Parameters:
value- JavaScript code to execute when the timeupdate event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
ontoggle
ontoggle attribute.Event handler for when a details element is opened or closed.
- Parameters:
value- JavaScript code to execute when the toggle event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onvolumechange
onvolumechange attribute.Event handler for when the volume of media changes.
- Parameters:
value- JavaScript code to execute when the volumechange event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
onwaiting
onwaiting attribute.Event handler for when media playback stops to buffer more data.
- Parameters:
value- JavaScript code to execute when the waiting event occurs. Can benull to unset the attribute.- Returns:
- This object.
-
setAttrs
Sets the attributes for this element.- Parameters:
value- The new attributes for this element. Can benull to clear all attributes.- Returns:
- This object.
-
spellcheck
spellcheck attribute.Indicates whether the element should have its spelling and grammar checked.
Possible values:
"true" - Enable spell checking for this element"false" - Disable spell checking for this element
- Parameters:
value- Whether spell checking should be enabled. Can benull to unset the attribute.- Returns:
- This object.
-
style
style attribute.Specifies inline CSS styles for the element. The value should be valid CSS property-value pairs separated by semicolons.
- Parameters:
value- Inline CSS styles (e.g.,"color: red; font-size: 14px;" ). Can benull to unset the attribute.- Returns:
- This object.
-
tabindex
tabindex attribute.Specifies the tab order of the element when navigating with the keyboard.
Possible values:
- Positive integer - Element is focusable and participates in tab order
"0" - Element is focusable but not in tab order- Negative integer - Element is not focusable
- Parameters:
value- The tab order value for keyboard navigation. Can benull to unset the attribute.- Returns:
- This object.
-
title
title attribute.Specifies additional information about the element, typically displayed as a tooltip when the user hovers over the element.
- Parameters:
value- Tooltip text to display on hover (e.g.,"Click to submit form" ). Can benull to unset the attribute.- Returns:
- This object.
-
toString
-
translate
translate attribute.Specifies whether the element's content should be translated when the page is localized.
Possible values:
"yes" - Content should be translated (default)"no" - Content should not be translated
- Parameters:
value- Whether the element content should be translated. Can benull to unset the attribute.- Returns:
- This object.
-
deminimize
If the specified attribute is a boolean, it gets converted to the attribute name iftrue ornull iffalse .- Parameters:
value- The attribute value. Can benull (returned as-is, sincenull is not aBoolean ).attr- The attribute name.- Returns:
- The deminimized value, or the same value if the value wasn't a boolean, or
null if the value was a booleanfalse .
-