Interface IBadge<I extends IAnyGroup>

All Superinterfaces:
IAnyGroup<IBadge<I>>, IChildable<IBadge<I>,I>, IComponent<IBadge<I>>, IHtmlBasedComponent<IBadge<I>>, IXulElement<IBadge<I>>

public interface IBadge<I extends IAnyGroup> extends IXulElement<IBadge<I>>, IChildable<IBadge<I>,I>, IAnyGroup<IBadge<I>>
Immutable Badge component.

A badge (count or status indicator). Used standalone, or wrapping a child component to pin the indicator onto it — see getPlacement(), which is only effective in that wrap mode.

Since:
11.0.0
Author:
peaker
See Also:
  • Badge
  • Field Details

    • DEFAULT

      static final IBadge<IAnyGroup> DEFAULT
      Constant for default attributes of this immutable component.
  • Method Details

    • getWidgetClass

      default String getWidgetClass()
      Returns the client widget class.

      Default: "zul.wgt.Badge"

      Specified by:
      getWidgetClass in interface IComponent<I extends IAnyGroup>
    • getValue

      @Nullable default String getValue()
      Returns the text value of this badge.

      Default: null. When non-null, takes precedence over getCount().

    • withValue

      IBadge<I> withValue(@Nullable String value)
      Returns a copy of this immutable component with the specified value.

      Sets the text value of this badge.

      Parameters:
      value - the text to show; takes precedence over getCount().

      Default: null.

      Returns:
      A modified copy of the this object
    • getCount

      default int getCount()
      Returns the count of this badge.

      Default: 0.

    • withCount

      IBadge<I> withCount(int count)
      Returns a copy of this immutable component with the specified count.

      Sets the count of this badge.

      Parameters:
      count - the number to show; must not be negative.

      Default: 0.

      Returns:
      A modified copy of the this object
      Throws:
      org.zkoss.zk.ui.WrongValueException - if count is negative
    • getMax

      default int getMax()
      Returns the maximum count to display before falling back to "{max}+".

      Default: 99.

    • withMax

      IBadge<I> withMax(int max)
      Returns a copy of this immutable component with the specified max.

      Sets the maximum count.

      Parameters:
      max - the cap above which "{max}+" is shown; must be at least 1.

      Default: 99.

      Returns:
      A modified copy of the this object
      Throws:
      org.zkoss.zk.ui.WrongValueException - if max is less than 1
    • isShowZero

      default boolean isShowZero()
      Returns whether to display when the count is zero.

      Default: false.

    • withShowZero

      IBadge<I> withShowZero(boolean showZero)
      Returns a copy of this immutable component with the specified showZero.

      Sets whether to display when the count is zero.

      Parameters:
      showZero - whether the badge shows when the count is zero.

      Default: false.

      Returns:
      A modified copy of the this object
    • isDot

      default boolean isDot()
      Returns whether to render as a small dot, ignoring value and count text.

      Default: false.

    • withDot

      IBadge<I> withDot(boolean dot)
      Returns a copy of this immutable component with the specified dot.

      Sets whether to render as a small dot, ignoring value and count text.

      Parameters:
      dot - whether to render as a dot instead of value/count text.

      Default: false.

      Returns:
      A modified copy of the this object
    • getSeverity

      @Nullable default String getSeverity()
      Returns the severity (color theme), or null when it was reset to the default.

      Default: "info".

    • withSeverity

      IBadge<I> withSeverity(@Nullable String severity)
      Returns a copy of this immutable component with the specified severity.

      Sets the severity.

      Parameters:
      severity - "info", "success", "warning", "error" or "neutral".

      Default: "info".

      Returns:
      A modified copy of the this object
      Throws:
      org.zkoss.zk.ui.WrongValueException - if severity is not one of the accepted tokens
    • getPlacement

      @Nullable default String getPlacement()
      Returns the placement of the indicator relative to the wrapped child, or null when it was reset to the default.

      Default: "top_right".

    • withPlacement

      IBadge<I> withPlacement(@Nullable String placement)
      Returns a copy of this immutable component with the specified placement.

      Sets the placement.

      Parameters:
      placement - "top_right", "top_left", "bottom_right" or "bottom_left".

      Default: "top_right".

      Returns:
      A modified copy of the this object
      Throws:
      org.zkoss.zk.ui.WrongValueException - if placement is not one of the accepted tokens
    • of

      static <I extends IAnyGroup> IBadge<I> of(int count)
      Returns the instance with the given count.
      Parameters:
      count - The count of the badge
    • of

      static <I extends IAnyGroup> IBadge<I> of(String value)
      Returns the instance with the given text value.
      Parameters:
      value - The text value of the badge
    • ofId

      static <I extends IAnyGroup> IBadge<I> ofId(String id)
      Returns the instance with the given id.
      Parameters:
      id - The id to identify this component