Package org.zkoss.stateless.sul
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>>
ImmutableBadgecomponent.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classIBadge.Builder<I extends IAnyGroup>Builds instances of typeIBadge.static classIBadge.UpdaterBuilds an updater of typeIBadgeforUiAgent.smartUpdate(Locator, SmartUpdater).
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default intgetCount()Returns the count of this badge.default intgetMax()Returns the maximum count to display before falling back to"{max}+".default java.lang.StringgetPlacement()Returns the placement of the indicator relative to the wrapped child, or null when it was reset to the default.default java.lang.StringgetSeverity()Returns the severity (color theme), or null when it was reset to the default.default java.lang.StringgetValue()Returns the text value of this badge.default java.lang.StringgetWidgetClass()Returns the client widget class.default booleanisDot()Returns whether to render as a small dot, ignoring value and count text.default booleanisShowZero()Returns whether to display when the count is zero.static <I extends IAnyGroup>
IBadge<I>of(int count)Returns the instance with the given count.static <I extends IAnyGroup>
IBadge<I>of(java.lang.String value)Returns the instance with the given text value.static <I extends IAnyGroup>
IBadge<I>ofId(java.lang.String id)Returns the instance with the given id.IBadge<I>withCount(int count)Returns a copy ofthisimmutable component with the specifiedcount.IBadge<I>withDot(boolean dot)Returns a copy ofthisimmutable component with the specifieddot.IBadge<I>withMax(int max)Returns a copy ofthisimmutable component with the specifiedmax.IBadge<I>withPlacement(java.lang.String placement)Returns a copy ofthisimmutable component with the specifiedplacement.IBadge<I>withSeverity(java.lang.String severity)Returns a copy ofthisimmutable component with the specifiedseverity.IBadge<I>withShowZero(boolean showZero)Returns a copy ofthisimmutable component with the specifiedshowZero.IBadge<I>withValue(java.lang.String value)Returns a copy ofthisimmutable component with the specifiedvalue.-
Methods inherited from interface org.zkoss.stateless.sul.IChildable
getChildren, withChildren, withChildren
-
Methods inherited from interface org.zkoss.stateless.sul.IComponent
getAction, getActions, getClientAttributes, getId, getMold, getWidgetListeners, getWidgetOverrides, isVisible, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withActions, withActions, withClientAttribute, withClientAttributes, withId, withMold, withVisible, withWidgetClass, withWidgetListener, withWidgetListeners, withWidgetOverride, withWidgetOverrides
-
Methods inherited from interface org.zkoss.stateless.sul.IHtmlBasedComponent
getClientAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getSkeleton, getStyle, getTabindex, getTooltiptext, getTop, getVflex, getWidth, getZclass, getZIndex, isFocus, withClientAction, withDraggable, withDroppable, withFocus, withHeight, withHflex, withLeft, withRenderdefer, withSclass, withSkeleton, withStyle, withTabindex, withTabindex, withTooltiptext, withTop, withVflex, withWidth, withZclass, withZIndex
-
Methods inherited from interface org.zkoss.stateless.sul.IXulElement
getContext, getCtrlKeys, getPopup, getTooltip, withContext, withCtrlKeys, withPopup, withTooltip
-
-
-
-
Method Detail
-
getWidgetClass
default java.lang.String getWidgetClass()
Returns the client widget class.Default:
"zul.wgt.Badge"- Specified by:
getWidgetClassin interfaceIComponent<I extends IAnyGroup>
-
getValue
@Nullable default java.lang.String getValue()
Returns the text value of this badge.Default:
null. When non-null, takes precedence overgetCount().
-
withValue
IBadge<I> withValue(@Nullable java.lang.String value)
Returns a copy ofthisimmutable component with the specifiedvalue.Sets the text value of this badge.
- Parameters:
value- the text to show; takes precedence overgetCount().Default:
null.- Returns:
- A modified copy of the
thisobject
-
getCount
default int getCount()
Returns the count of this badge.Default:
0.
-
withCount
IBadge<I> withCount(int count)
Returns a copy ofthisimmutable component with the specifiedcount.Sets the count of this badge.
- Parameters:
count- the number to show; must not be negative.Default:
0.- Returns:
- A modified copy of the
thisobject - Throws:
org.zkoss.zk.ui.WrongValueException- ifcountis 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 ofthisimmutable component with the specifiedmax.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
thisobject - Throws:
org.zkoss.zk.ui.WrongValueException- ifmaxis 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 ofthisimmutable component with the specifiedshowZero.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
thisobject
-
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 ofthisimmutable component with the specifieddot.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
thisobject
-
getSeverity
@Nullable default java.lang.String getSeverity()
Returns the severity (color theme), or null when it was reset to the default.Default:
"info".
-
withSeverity
IBadge<I> withSeverity(@Nullable java.lang.String severity)
Returns a copy ofthisimmutable component with the specifiedseverity.Sets the severity.
- Parameters:
severity-"info","success","warning","error"or"neutral".Default:
"info".- Returns:
- A modified copy of the
thisobject - Throws:
org.zkoss.zk.ui.WrongValueException- ifseverityis not one of the accepted tokens
-
getPlacement
@Nullable default java.lang.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 java.lang.String placement)
Returns a copy ofthisimmutable component with the specifiedplacement.Sets the placement.
- Parameters:
placement-"top_right","top_left","bottom_right"or"bottom_left".Default:
"top_right".- Returns:
- A modified copy of the
thisobject - Throws:
org.zkoss.zk.ui.WrongValueException- ifplacementis 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(java.lang.String value)
Returns the instance with the given text value.- Parameters:
value- The text value of the badge
-
-