Class MenuItem
java.lang.Object
org.apache.juneau.console.widgets.MenuItem
A single row in an attached header or avatar menu.
A menu item is exactly one of a link (same-origin navigation), a safe (format-validated client-event
token, host-interpreted), or a divider (a separator row). Dividers are exempt from the id/label/href/
safe rules entirely: a fail-closed validate must not reject a real menu just because it contains a separator, and
divider() mints no id.
- Since:
- 10.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionWhenBoolean.TRUE, this is a separator row and all other fields are ignored.A same-origin navigation target (link item); ignored for dividers.Optional icon-registry name, hydrated client-side fromdata-juneau-icon.Required + unique for link/safe items; ignored for dividers.The row text, painted astextContent; ignored for dividers.A format-validated client-event token (safe item); ignored for dividers. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic MenuItemdivider()Creates a divider (separator) row.Sets the optional icon-registry name.booleanWhether this item is a divider (separator) row.static MenuItemCreates a navigation (link) menu item.static MenuItemCreates a client-safe menu item.voidvalidate()Fail-closed bean validation; called by the enclosing menu host.
-
Field Details
-
id
Required + unique for link/safe items; ignored for dividers. -
label
The row text, painted astextContent; ignored for dividers. -
icon
Optional icon-registry name, hydrated client-side fromdata-juneau-icon. -
href
A same-origin navigation target (link item); ignored for dividers. -
safe
A format-validated client-event token (safe item); ignored for dividers. -
divider
WhenBoolean.TRUE, this is a separator row and all other fields are ignored.
-
-
Constructor Details
-
MenuItem
public MenuItem()
-
-
Method Details
-
link
Creates a navigation (link) menu item.- Parameters:
id- The stable item id. Must not benull or blank.label- The row text. Must not benull or blank.href- The same-origin navigation target. Must not benull or blank.- Returns:
- A new
MenuItem.
-
safe
Creates a client-safe menu item.- Parameters:
id- The stable item id. Must not benull or blank.label- The row text. Must not benull or blank.safeToken- The client-event token; must match^[a-z][a-z0-9-]{0,63}$.- Returns:
- A new
MenuItem.
-
divider
Creates a divider (separator) row. Needs no id — it is exempt from the unique-id rule.- Returns:
- A new divider
MenuItem.
-
icon
Sets the optional icon-registry name.- Parameters:
value- The icon name.- Returns:
- This object.
-
isDivider
Whether this item is a divider (separator) row.- Returns:
true if this is a divider.
-
validate
Fail-closed bean validation; called by the enclosing menu host.Dividers are exempt: a divider validates trivially regardless of its other (ignored) fields.
- Throws:
IllegalArgumentException- If this menu item is not well-formed.
-