Interface HasElement<E extends Element,B extends TypedBuilder<E,B>>

All Superinterfaces:
IsElement<E>, TypedBuilder<E,B>
All Known Implementing Classes:
HTMLContainerBuilder, HTMLElementBuilder, InputElementBuilder

public interface HasElement<E extends Element,B extends TypedBuilder<E,B>> extends TypedBuilder<E,B>, IsElement<E>
Provides methods and default implementations for modifying elements.
  • Method Summary

    Modifier and Type
    Method
    Description
    default B
    add(String text)
    Adds the given text as a text node.
    default B
    apply(Consumer<E> consumer)
    Provides a way to modify the wrapped element using the specified consumer.
    default B
    aria(String name, boolean value)
    Adds an aria- attribute to the element.
    default B
    aria(String name, int value)
    Adds an aria- attribute to the element.
    default B
    aria(String name, String value)
    Adds an aria- attribute to the element.
    default B
    attr(String name, boolean value)
    Sets the specified attribute of the element.
    default B
    attr(String name, int value)
    Sets the specified attribute of the element.
    default B
    attr(String name, String value)
    Sets the specified attribute of the element.
    default ClassList<E>
     
    default B
     
    default B
    css(String... classes)
    Adds the specified CSS classes to the class list of the element.
    default B
    id(String id)
    Sets the id on the element.
    default B
    Modifies the inner HTML on the element using Element.innerHTML.
    default <V extends Event>
    B
    on(EventType<V,?> type, boolean useCapture, EventCallbackFn<V> callback)
     
    default <V extends Event>
    B
    on(EventType<V,?> type, AddEventListenerOptions options, EventCallbackFn<V> callback)
     
    default <V extends Event>
    B
    on(EventType<V,?> type, EventCallbackFn<V> callback)
    Adds the given callback to the element.
    default B
    run(Consumer<B> consumer)
    Executes code in the context of this builder.
    default B
    Sets the inner text on the element using Node.textContent.
    default B
    Changes the text of the first text node (if any) or adds the given text as a new text node.
    default B
    toggle(String className)
    Toggle the class value; i.e., if the class exists then remove it, if not, then add it.
    default B
    toggle(String className, boolean force)
    Adds (force=true) or removes (force=false) the specified CSS class to the class list of the element.
    default B
    toggle(String className, Supplier<Boolean> force)
    Adds (force=true) or removes (force=false) the specified CSS class to the class list of the element.
    default B
    Generates and sets an unique id on the element.

    Methods inherited from interface org.jboss.elemento.IsElement

    element

    Methods inherited from interface org.jboss.elemento.TypedBuilder

    that
  • Method Details

    • uniqueId

      default B uniqueId()
      Generates and sets an unique id on the element.
    • id

      default B id(String id)
      Sets the id on the element.
    • textContent

      default B textContent(String text)
      Sets the inner text on the element using Node.textContent. If you want to preserve existing child elements and just want to change the text of the text node, use textNode(String).
    • textNode

      default B textNode(String text)
      Changes the text of the first text node (if any) or adds the given text as a new text node. Use this method instead of Node.textContent if you want to preserve existing child elements.
    • add

      default B add(String text)
      Adds the given text as a text node.
    • innerHtml

      default B innerHtml(SafeHtml html)
      Modifies the inner HTML on the element using Element.innerHTML.
    • css

      default B css(String... classes)
      Adds the specified CSS classes to the class list of the element.
    • toggle

      default B toggle(String className)
      Toggle the class value; i.e., if the class exists then remove it, if not, then add it.
    • toggle

      default B toggle(String className, boolean force)
      Adds (force=true) or removes (force=false) the specified CSS class to the class list of the element.
    • toggle

      default B toggle(String className, Supplier<Boolean> force)
      Adds (force=true) or removes (force=false) the specified CSS class to the class list of the element.
    • classList

      default B classList(Consumer<ClassList<E>> classList)
    • classList

      default ClassList<E> classList()
    • attr

      default B attr(String name, boolean value)
      Sets the specified attribute of the element.
    • attr

      default B attr(String name, int value)
      Sets the specified attribute of the element.
    • attr

      default B attr(String name, String value)
      Sets the specified attribute of the element.
    • aria

      default B aria(String name, boolean value)
      Adds an aria- attribute to the element.
      Parameters:
      name - The name of the aria attribute w/o the aria- prefix. However it won't be added if it's already present.
    • aria

      default B aria(String name, int value)
      Adds an aria- attribute to the element.
      Parameters:
      name - The name of the aria attribute w/o the aria- prefix. However it won't be added if it's already present.
    • aria

      default B aria(String name, String value)
      Adds an aria- attribute to the element.
      Parameters:
      name - The name of the aria attribute w/o the aria- prefix. However it won't be added if it's already present.
    • apply

      default B apply(Consumer<E> consumer)
      Provides a way to modify the wrapped element using the specified consumer.
    • run

      default B run(Consumer<B> consumer)
      Executes code in the context of this builder.
    • on

      default <V extends Event> B on(EventType<V,?> type, EventCallbackFn<V> callback)
      Adds the given callback to the element.

      HTMLLIElement listItem = li()
              .add(div().css("view")
                      .add(input(checkbox)
                              .css("toggle")
                              .on(change, event -> ...))
                      .add(label()
                              .textContent("Taste Elemento")
                              .on(dblclick, event -> ...))
                      .add(button()
                              .css("destroy")
                              .on(click, event -> ...)))
              .add(input(text)
                      .css("edit")
                      .on(keydown, event -> ...)
                      .on(blur, event -> ...))
              .element();
      
    • on

      default <V extends Event> B on(EventType<V,?> type, boolean useCapture, EventCallbackFn<V> callback)
    • on

      default <V extends Event> B on(EventType<V,?> type, AddEventListenerOptions options, EventCallbackFn<V> callback)