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 SummaryConstructors
- 
Method SummaryModifier 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 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.Sets the attributes for this element.spellcheck(Object value) spellcheck attribute.style attribute.tabindex attribute.title attribute.toString()translate attribute.
- 
Constructor Details- 
HtmlElementpublic HtmlElement()
 
- 
- 
Method Details- 
getAttrsThe attributes of this element.- Returns:
- The attributes of this element.
 
- 
setAttrsSets the attributes for this element.- Parameters:
- attrs- The new attributes for this element.
- Returns:
- This object.
 
- 
attrAdds an arbitrary attribute to this element.- Parameters:
- key- The attribute name.
- val- The attribute value.
- Returns:
- This object.
 
- 
attrUriAdds 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.
- Returns:
- This object.
 
- 
getAttrReturns the attribute with the specified name.- Parameters:
- key- The attribute name.
- Returns:
- The attribute value, or null if the named attribute does not exist.
 
- 
getAttrReturns 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. See- ConverterUtilsfor a list of supported conversion types.
- key- The attribute name.
- Returns:
- The attribute value, or null if the named attribute does not exist.
 
- 
accesskeyaccesskey 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.
 
- 
_classclass 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.
 
- 
contenteditablecontenteditable 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.
 
- 
dirdir 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.
 
- 
idid 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.
 
- 
langlang 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.
 
- 
onabortonabort 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.
 
- 
onbluronblur 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: 
- 
oncanceloncancel attribute.Event handler for when a dialog is cancelled. - Parameters:
- oncancel- JavaScript code to execute when the cancel event occurs.
- Returns:
- This object.
 
- 
oncanplayoncanplay 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.
 
- 
oncanplaythroughoncanplaythrough 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.
 
- 
onchangeonchange 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: 
- 
onclickonclick 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: 
- 
oncuechangeoncuechange attribute.Event handler for when a text track cue changes. - Parameters:
- oncuechange- JavaScript code to execute when the cuechange event occurs.
- Returns:
- This object.
 
- 
ondblclickondblclick attribute.Event handler for when the element is double-clicked. - Parameters:
- ondblclick- JavaScript code to execute when the dblclick event occurs.
- Returns:
- This object.
 
- 
ondurationchangeondurationchange 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.
 
- 
onemptiedonemptied 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.
 
- 
onendedonended 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.
 
- 
onerroronerror 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.
 
- 
onfocusonfocus 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: 
- 
oninputoninput 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.
 
- 
oninvalidoninvalid attribute.Event handler for when form validation fails. - Parameters:
- oninvalid- JavaScript code to execute when the invalid event occurs.
- Returns:
- This object.
 
- 
onkeydownonkeydown attribute.Event handler for when a key is pressed down. - Parameters:
- onkeydown- JavaScript code to execute when the keydown event occurs.
- Returns:
- This object.
 
- 
onkeypressonkeypress 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.
 
- 
onkeyuponkeyup attribute.Event handler for when a key is released. - Parameters:
- onkeyup- JavaScript code to execute when the keyup event occurs.
- Returns:
- This object.
 
- 
onloadonload 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: 
- 
onloadeddataonloadeddata 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.
 
- 
onloadedmetadataonloadedmetadata 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.
 
- 
onloadstartonloadstart 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.
 
- 
onmousedownonmousedown 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.
 
- 
onmouseenteronmouseenter 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.
 
- 
onmouseleaveonmouseleave 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.
 
- 
onmousemoveonmousemove 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.
 
- 
onmouseoutonmouseout 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.
 
- 
onmouseoveronmouseover 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: 
- 
onmouseuponmouseup 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.
 
- 
onmousewheelonmousewheel 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.
 
- 
onpauseonpause attribute.Event handler for when media playback is paused. - Parameters:
- onpause- JavaScript code to execute when the pause event occurs.
- Returns:
- This object.
 
- 
onplayonplay attribute.Event handler for when media playback starts. - Parameters:
- onplay- JavaScript code to execute when the play event occurs.
- Returns:
- This object.
 
- 
onplayingonplaying 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.
 
- 
onprogressonprogress 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.
 
- 
onratechangeonratechange 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.
 
- 
onresetonreset attribute.Event handler for when a form is reset. - Parameters:
- onreset- JavaScript code to execute when the reset event occurs.
- Returns:
- This object.
 
- 
onresizeonresize attribute.Event handler for when the element is resized. - Parameters:
- onresize- JavaScript code to execute when the resize event occurs.
- Returns:
- This object.
 
- 
onscrollonscroll 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.
 
- 
onseekedonseeked attribute.Event handler for when a seek operation completes. - Parameters:
- onseeked- JavaScript code to execute when the seeked event occurs.
- Returns:
- This object.
 
- 
onseekingonseeking attribute.Event handler for when a seek operation begins. - Parameters:
- onseeking- JavaScript code to execute when the seeking event occurs.
- Returns:
- This object.
 
- 
onselectonselect 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.
 
- 
onshowonshow attribute.Event handler for when a context menu is shown. - Parameters:
- onshow- JavaScript code to execute when the show event occurs.
- Returns:
- This object.
 
- 
onstalledonstalled attribute.Event handler for when media loading is stalled. - Parameters:
- onstalled- JavaScript code to execute when the stalled event occurs.
- Returns:
- This object.
 
- 
onsubmitonsubmit 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: 
- 
onsuspendonsuspend attribute.Event handler for when media loading is suspended. - Parameters:
- onsuspend- JavaScript code to execute when the suspend event occurs.
- Returns:
- This object.
 
- 
ontimeupdateontimeupdate attribute.Event handler for when the current playback position changes. - Parameters:
- ontimeupdate- JavaScript code to execute when the timeupdate event occurs.
- Returns:
- This object.
 
- 
ontoggleontoggle 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.
 
- 
onvolumechangeonvolumechange attribute.Event handler for when the volume of media changes. - Parameters:
- onvolumechange- JavaScript code to execute when the volumechange event occurs.
- Returns:
- This object.
 
- 
onwaitingonwaiting 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.
 
- 
spellcheckspellcheck 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.
 
- 
stylestyle 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.
 
- 
tabindextabindex 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.
 
- 
titletitle 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.
 
- 
translatetranslate 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.
 
- 
deminimizeIf 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
 
-