Class AlertGroup

All Implemented Interfaces:
Iterable<Alert>, ElementAttributeMethods<HTMLUListElement, AlertGroup>, ElementClassListMethods<HTMLUListElement, AlertGroup>, ElementConsumerMethods<HTMLUListElement, AlertGroup>, ElementContainerMethods<HTMLUListElement, AlertGroup>, ElementEventMethods<HTMLUListElement, AlertGroup>, ElementIdMethods<HTMLUListElement, AlertGroup>, ElementQueryMethods<HTMLUListElement>, HTMLElementAttributeMethods<HTMLUListElement, AlertGroup>, HTMLElementDataMethods<HTMLUListElement, AlertGroup>, HTMLElementStyleMethods<HTMLUListElement, AlertGroup>, HTMLElementVisibilityMethods<HTMLUListElement, AlertGroup>, IsElement<HTMLUListElement>, TypedBuilder<HTMLUListElement, AlertGroup>, Component, HasItems<HTMLUListElement, AlertGroup, Alert>

public class AlertGroup extends BaseComponent<HTMLUListElement, AlertGroup> implements HasItems<HTMLUListElement, AlertGroup, Alert>
An alert group stacks and positions 2 or more alerts in a live region, either in a layer over the main content of a page or inline with the page content. Alert groups should always rank alerts by age, stacking new alerts on top of old ones as they surface.
See Also:
  • Method Details

    • alertGroup

      public static AlertGroup alertGroup(AlertGroupType type)
      Creates a new alert group of the given type without a timeout.

      If the type is AlertGroupType.toast the alert group is added to the body or if it already has been added the existing alert group is returned (singleton pattern).

    • alertGroup

      public static AlertGroup alertGroup(AlertGroupType type, int timeout)
      Creates a new alert group of the given type and timeout.

      If the type is AlertGroupType.toast the alert group is added to the body or if it already has been added the existing toast alert group is returned (singleton pattern).

    • toastAlertGroup

      public static AlertGroup toastAlertGroup()
    • add

      public AlertGroup add(Alert alert)
      Description copied from interface: HasItems
      Adds an item to the component.
      Specified by:
      add in interface HasItems<HTMLUListElement, AlertGroup, Alert>
      Parameters:
      alert - the item to be added to the component
      Returns:
      the builder instance after the item has been added
    • that

      public AlertGroup that()
      Specified by:
      that in interface TypedBuilder<HTMLUListElement, AlertGroup>
    • onAdd

      public AlertGroup onAdd(AddItemHandler<AlertGroup, Alert> onAdd)
      Description copied from interface: HasItems
      Registers a callback to be invoked whenever a new item is added to the component.
      Specified by:
      onAdd in interface HasItems<HTMLUListElement, AlertGroup, Alert>
      Parameters:
      onAdd - a AddItemHandler that takes the builder instance and the item being added as arguments
      Returns:
      the builder instance after adding the callback
    • onUpdate

      public AlertGroup onUpdate(UpdateItemHandler<AlertGroup, Alert> onUpdate)
      Description copied from interface: HasItems
      Registers a callback to be invoked whenever an item is updated in the component.
      Specified by:
      onUpdate in interface HasItems<HTMLUListElement, AlertGroup, Alert>
      Parameters:
      onUpdate - a UpdateItemHandler that takes the component, the previous state of the item, and the updated state of the item as arguments
      Returns:
      the builder instance after adding the callback
    • onRemove

      public AlertGroup onRemove(RemoveItemHandler<AlertGroup, Alert> onRemove)
      Description copied from interface: HasItems
      Registers a callback to be invoked whenever an item is removed from the component.
      Specified by:
      onRemove in interface HasItems<HTMLUListElement, AlertGroup, Alert>
      Parameters:
      onRemove - a RemoveItemHandler that takes the component and the item being removed as arguments
      Returns:
      the builder instance after adding the callback
    • iterator

      public Iterator<Alert> iterator()
      Specified by:
      iterator in interface Iterable<Alert>
    • size

      public int size()
      Description copied from interface: HasItems
      Retrieves the total number of items currently contained in the component.
      Specified by:
      size in interface HasItems<HTMLUListElement, AlertGroup, Alert>
      Returns:
      the number of items contained in the component
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: HasItems
      Checks whether the collection of items in the component is empty.
      Specified by:
      isEmpty in interface HasItems<HTMLUListElement, AlertGroup, Alert>
      Returns:
      true if the component contains no items; false otherwise
    • contains

      public boolean contains(String identifier)
      Description copied from interface: HasItems
      Checks whether the component contains an item associated with the given identifier.
      Specified by:
      contains in interface HasItems<HTMLUListElement, AlertGroup, Alert>
      Parameters:
      identifier - the identifier of the item to be checked
      Returns:
      true if the component contains an item associated with the provided identifier, false otherwise
    • item

      public Alert item(String identifier)
      Description copied from interface: HasItems
      Retrieves the item associated with the specified identifier from the component.
      Specified by:
      item in interface HasItems<HTMLUListElement, AlertGroup, Alert>
      Parameters:
      identifier - the identifier of the item to be retrieved
      Returns:
      the item associated with the given identifier, or null if no item is found
    • updateItem

      public void updateItem(Alert item)
      Description copied from interface: HasItems
      Updates an existing item in the component.
      Specified by:
      updateItem in interface HasItems<HTMLUListElement, AlertGroup, Alert>
      Parameters:
      item - the item to be updated
    • removeItem

      public void removeItem(String identifier)
      Description copied from interface: HasItems
      Removes an item from the component based on the provided identifier.
      Specified by:
      removeItem in interface HasItems<HTMLUListElement, AlertGroup, Alert>
      Parameters:
      identifier - the identifier of the item to be removed
    • clear

      public void clear()
      Description copied from interface: HasItems
      Clears all items from the component. This method removes any existing items within the component, leaving it empty. Any associated or registered callbacks related to the removal of items may be invoked as part of this operation.
      Specified by:
      clear in interface HasItems<HTMLUListElement, AlertGroup, Alert>