Class HtmlElement
- 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 TypeMethodDescriptionclass attribute.accesskey attribute.Adds an arbitrary attribute to this element.Adds an arbitrary URI attribute to this element.contenteditable
(Object value) contenteditable attribute.protected Object
deminimize
(Object value, String attr) If the specified attribute is a boolean, it gets converted to the attribute name iftrue ornull iffalse .dir attribute.<T> T
Returns 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.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
-
getAttrs
The attributes of this element.- Returns:
- The attributes of this element.
-
setAttrs
Sets the attributes for this element.- Parameters:
attrs
- The new attributes for this element.- Returns:
- This object.
-
attr
Adds an arbitrary attribute to this element.- Parameters:
key
- The attribute name.val
- The attribute value.- 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
UriResolver
can be used for values.- Parameters:
key
- The attribute name.val
- The attribute value.- Returns:
- This object.
-
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.
-
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. SeeConverterUtils
for a list of supported conversion types.key
- The attribute name.- Returns:
- The attribute value, or
null if the named attribute does not exist.
-
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:
accesskey
- The keyboard shortcut character (e.g.,"a" ,"1" ).- Returns:
- This object.
-
_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:
_class
- Space-separated CSS class names (e.g.,"btn btn-primary" ).- 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:
contenteditable
- The editability state of the element.- 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:
dir
- The text direction for the element.- Returns:
- This object.
-
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:
id
- A unique identifier for the element (e.g.,"header" ,"main-content" ).- 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:
lang
- A language tag (e.g.,"en" ,"en-US" ,"es" ,"fr-CA" ).- Returns:
- This object.
-
onabort
onabort attribute.Event handler for when an operation is aborted (e.g., image loading is cancelled).
- Parameters:
onabort
- JavaScript code to execute when the abort event occurs.- 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:
onblur
- JavaScript code to execute when the element loses focus.- Returns:
- This object.
- If using single quotes for attributes:
-
oncancel
oncancel attribute.Event handler for when a dialog is cancelled.
- Parameters:
oncancel
- JavaScript code to execute when the cancel event occurs.- Returns:
- This object.
-
oncanplay
oncanplay attribute.Event handler for when the media can start playing (enough data has been buffered).
- Parameters:
oncanplay
- JavaScript code to execute when the canplay event occurs.- Returns:
- This object.
-
oncanplaythrough
oncanplaythrough attribute.Event handler for when the media can play through to the end without buffering.
- Parameters:
oncanplaythrough
- JavaScript code to execute when the canplaythrough event occurs.- 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:
onchange
- JavaScript code to execute when the change event occurs.- 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:
onclick
- JavaScript code to execute when the click event occurs.- Returns:
- This object.
- If using single quotes for attributes:
-
oncuechange
oncuechange attribute.Event handler for when a text track cue changes.
- Parameters:
oncuechange
- JavaScript code to execute when the cuechange event occurs.- Returns:
- This object.
-
ondblclick
ondblclick attribute.Event handler for when the element is double-clicked.
- Parameters:
ondblclick
- JavaScript code to execute when the dblclick event occurs.- Returns:
- This object.
-
ondurationchange
ondurationchange attribute.Event handler for when the duration of the media changes.
- Parameters:
ondurationchange
- JavaScript code to execute when the durationchange event occurs.- Returns:
- This object.
-
onemptied
onemptied attribute.Event handler for when the media element becomes empty (e.g., network error).
- Parameters:
onemptied
- JavaScript code to execute when the emptied event occurs.- Returns:
- This object.
-
onended
onended attribute.Event handler for when the media playback reaches the end.
- Parameters:
onended
- JavaScript code to execute when the ended event occurs.- Returns:
- This object.
-
onerror
onerror attribute.Event handler for when an error occurs (e.g., failed resource loading).
- Parameters:
onerror
- JavaScript code to execute when the error event occurs.- 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:
onfocus
- JavaScript code to execute when the focus event occurs.- 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:
oninput
- JavaScript code to execute when the input event occurs.- Returns:
- This object.
-
oninvalid
oninvalid attribute.Event handler for when form validation fails.
- Parameters:
oninvalid
- JavaScript code to execute when the invalid event occurs.- Returns:
- This object.
-
onkeydown
onkeydown attribute.Event handler for when a key is pressed down.
- Parameters:
onkeydown
- JavaScript code to execute when the keydown event occurs.- Returns:
- This object.
-
onkeypress
onkeypress attribute.Event handler for when a key is pressed (deprecated, use onkeydown instead).
- Parameters:
onkeypress
- JavaScript code to execute when the keypress event occurs.- Returns:
- This object.
-
onkeyup
onkeyup attribute.Event handler for when a key is released.
- Parameters:
onkeyup
- JavaScript code to execute when the keyup event occurs.- 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:
onload
- JavaScript code to execute when the load event occurs.- 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:
onloadeddata
- JavaScript code to execute when the loadeddata event occurs.- Returns:
- This object.
-
onloadedmetadata
onloadedmetadata attribute.Event handler for when metadata (duration, dimensions, etc.) has been loaded.
- Parameters:
onloadedmetadata
- JavaScript code to execute when the loadedmetadata event occurs.- Returns:
- This object.
-
onloadstart
onloadstart attribute.Event handler for when the browser starts loading the media.
- Parameters:
onloadstart
- JavaScript code to execute when the loadstart event occurs.- Returns:
- This object.
-
onmousedown
onmousedown attribute.Event handler for when a mouse button is pressed down on the element.
- Parameters:
onmousedown
- JavaScript code to execute when the mousedown event occurs.- Returns:
- This object.
-
onmouseenter
onmouseenter attribute.Event handler for when the mouse pointer enters the element (does not bubble).
- Parameters:
onmouseenter
- JavaScript code to execute when the mouseenter event occurs.- Returns:
- This object.
-
onmouseleave
onmouseleave attribute.Event handler for when the mouse pointer leaves the element (does not bubble).
- Parameters:
onmouseleave
- JavaScript code to execute when the mouseleave event occurs.- Returns:
- This object.
-
onmousemove
onmousemove attribute.Event handler for when the mouse pointer moves over the element.
- Parameters:
onmousemove
- JavaScript code to execute when the mousemove event occurs.- Returns:
- This object.
-
onmouseout
onmouseout attribute.Event handler for when the mouse pointer moves out of the element (bubbles).
- Parameters:
onmouseout
- JavaScript code to execute when the mouseout event occurs.- 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:
onmouseover
- JavaScript code to execute when the mouseover event occurs.- 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:
onmouseup
- JavaScript code to execute when the mouseup event occurs.- Returns:
- This object.
-
onmousewheel
onmousewheel attribute.Event handler for when the mouse wheel is rotated over the element (deprecated, use onwheel).
- Parameters:
onmousewheel
- JavaScript code to execute when the mousewheel event occurs.- Returns:
- This object.
-
onpause
onpause attribute.Event handler for when media playback is paused.
- Parameters:
onpause
- JavaScript code to execute when the pause event occurs.- Returns:
- This object.
-
onplay
onplay attribute.Event handler for when media playback starts.
- Parameters:
onplay
- JavaScript code to execute when the play event occurs.- Returns:
- This object.
-
onplaying
onplaying attribute.Event handler for when media playback starts after being paused or delayed.
- Parameters:
onplaying
- JavaScript code to execute when the playing event occurs.- Returns:
- This object.
-
onprogress
onprogress attribute.Event handler for when the browser is downloading media data.
- Parameters:
onprogress
- JavaScript code to execute when the progress event occurs.- Returns:
- This object.
-
onratechange
onratechange attribute.Event handler for when the playback rate of media changes.
- Parameters:
onratechange
- JavaScript code to execute when the ratechange event occurs.- Returns:
- This object.
-
onreset
onreset attribute.Event handler for when a form is reset.
- Parameters:
onreset
- JavaScript code to execute when the reset event occurs.- Returns:
- This object.
-
onresize
onresize attribute.Event handler for when the element is resized.
- Parameters:
onresize
- JavaScript code to execute when the resize event occurs.- Returns:
- This object.
-
onscroll
onscroll attribute.Event handler for when the element's scrollbar is scrolled.
- Parameters:
onscroll
- JavaScript code to execute when the scroll event occurs.- Returns:
- This object.
-
onseeked
onseeked attribute.Event handler for when a seek operation completes.
- Parameters:
onseeked
- JavaScript code to execute when the seeked event occurs.- Returns:
- This object.
-
onseeking
onseeking attribute.Event handler for when a seek operation begins.
- Parameters:
onseeking
- JavaScript code to execute when the seeking event occurs.- Returns:
- This object.
-
onselect
onselect attribute.Event handler for when text is selected in the element.
- Parameters:
onselect
- JavaScript code to execute when the select event occurs.- Returns:
- This object.
-
onshow
onshow attribute.Event handler for when a context menu is shown.
- Parameters:
onshow
- JavaScript code to execute when the show event occurs.- Returns:
- This object.
-
onstalled
onstalled attribute.Event handler for when media loading is stalled.
- Parameters:
onstalled
- JavaScript code to execute when the stalled event occurs.- 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:
onsubmit
- JavaScript code to execute when the submit event occurs.- Returns:
- This object.
- If using single quotes for attributes:
-
onsuspend
onsuspend attribute.Event handler for when media loading is suspended.
- Parameters:
onsuspend
- JavaScript code to execute when the suspend event occurs.- Returns:
- This object.
-
ontimeupdate
ontimeupdate attribute.Event handler for when the current playback position changes.
- Parameters:
ontimeupdate
- JavaScript code to execute when the timeupdate event occurs.- Returns:
- This object.
-
ontoggle
ontoggle attribute.Event handler for when a details element is opened or closed.
- Parameters:
ontoggle
- JavaScript code to execute when the toggle event occurs.- Returns:
- This object.
-
onvolumechange
onvolumechange attribute.Event handler for when the volume of media changes.
- Parameters:
onvolumechange
- JavaScript code to execute when the volumechange event occurs.- Returns:
- This object.
-
onwaiting
onwaiting attribute.Event handler for when media playback stops to buffer more data.
- Parameters:
onwaiting
- JavaScript code to execute when the waiting event occurs.- 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:
spellcheck
- Whether spell checking should be enabled.- 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:
style
- Inline CSS styles (e.g.,"color: red; font-size: 14px;" ).- 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:
tabindex
- The tab order value for keyboard navigation.- 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:
title
- Tooltip text to display on hover (e.g.,"Click to submit form" ).- Returns:
- This object.
-
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:
translate
- Whether the element content should be translated.- 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.attr
- The attribute name.- Returns:
- The deminimized value, or the same value if the value wasn't a boolean.
-
toString
-