Class MenuItem

java.lang.Object
org.apache.juneau.console.widgets.MenuItem

@BeanType(properties="id,label,icon,href,safe,divider") public class MenuItem extends Object
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 Details

    • id

      public String id
      Required + unique for link/safe items; ignored for dividers.
    • label

      public String label
      The row text, painted as textContent; ignored for dividers.
    • icon

      public String icon
      Optional icon-registry name, hydrated client-side from data-juneau-icon.
    • href

      public String href
      A same-origin navigation target (link item); ignored for dividers.
    • safe

      public String safe
      A format-validated client-event token (safe item); ignored for dividers.
    • divider

      public Boolean divider
      When Boolean.TRUE, this is a separator row and all other fields are ignored.
  • Constructor Details

  • Method Details

    • link

      public static MenuItem link(String id, String label, String href)
      Creates a navigation (link) menu item.
      Parameters:
      id - The stable item id. Must not be null or blank.
      label - The row text. Must not be null or blank.
      href - The same-origin navigation target. Must not be null or blank.
      Returns:
      A new MenuItem.
    • safe

      public static MenuItem safe(String id, String label, String safeToken)
      Creates a client-safe menu item.
      Parameters:
      id - The stable item id. Must not be null or blank.
      label - The row text. Must not be null or blank.
      safeToken - The client-event token; must match ^[a-z][a-z0-9-]{0,63}$.
      Returns:
      A new MenuItem.
    • divider

      public static MenuItem divider()
      Creates a divider (separator) row. Needs no id — it is exempt from the unique-id rule.
      Returns:
      A new divider MenuItem.
    • icon

      public MenuItem icon(String value)
      Sets the optional icon-registry name.
      Parameters:
      value - The icon name.
      Returns:
      This object.
    • isDivider

      public boolean isDivider()
      Whether this item is a divider (separator) row.
      Returns:
      true if this is a divider.
    • validate

      public void 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.