1. Domino UI
  2. Components
  3. Menu
Top Basic Header Search Custom Features Embed Dropdown Context nested Docs

Menu

Menu

Represents a UI Menu component that supports different configurations, items, and behaviors.

Usage Example:

 
 Menu  myMenu = Menu.create()
    .setTitle("My Menu")
    .setIcon(Icons.ALL.menu())
    .appendChild(new MenuItem< >("Menu Item 1"));
 

V

The type of the item value that the menu holds.

See also :

Menu item

Represents a menu item that can be added to a menu. Each menu item can have a text and an optional description.

V

the type of value associated with this menu item

Anatomy

menu-anatomy.
  1. Menu header, can have optional icon, title and header actions.
  2. Menu search, a search box to filter menu items.
  3. Menu sub-header, an extra header to fit other components.
  4. Menu items, each item can have an icon, title, description, postfix.
  5. Menu custom items, are menu items that fits in any other set of components.
  6. Nested menu, menu items can nest other sub-menus.
  7. Menu items with description and postfix icon.

Examples

Basic menu Simple menu with menu items

Menu headers Menu with header actions and sub-header

Custom menu items Menu items with custom content.

Menu features Mix and match different features.

Embed menu Embed menu inside other components.

Dropdown menu Use menu as a drop-down menu for other components.

Context menu Use menu as a right click context menu.

Nested menu items Menu items can nest other menus.

API Docs: Menu

Constructors

public void Menu()
Default constructor to initialize the Menu component.

Static methods

public static Menu<V> create()
Factory method to create a new Menu instance.

V

The type of the menu item value.



Returns:

A new menu instance.

Public methods

public Menu<V> appendChild(AbstractMenuItem<V> menuItem)
Appends a menu item to the menu.

menuItem

The menu item to be added.



Returns:

The current Menu instance.

public Menu<V> insertChild(int index, AbstractMenuItem<V> menuItem)
Inserts a menu item to the menu at the specified index, the index should be within the valid range otherwise an exception is thrown.

index

The index to insert the menu item at.

menuItem

The menu item to be added.



Returns:

The current Menu instance.

public Menu<V> appendChild(MenuItemsGroup<V> menuGroup, MenuItemsGroupHandler<V, I> groupHandler)
Appends a menu items group to the menu with a provided handler.

I

The type of the abstract menu item.

menuGroup

The menu items group to be added.

groupHandler

The handler for the menu items group.



Returns:

The current Menu instance.

public Menu<V> insertGroup(int index, MenuItemsGroup<V> menuGroup, MenuItemsGroupHandler<V, I> groupHandler)
Inserts a menu items group to the menu at the specified index, the index should be within the valid range otherwise an exception is thrown.

index

The index to insert the menu items group at.

I

The type of the abstract menu item.

menuGroup

The menu items group to be added.

groupHandler

The handler for the menu items group.



Returns:

The current Menu instance.

public Menu<V> removeItem(AbstractMenuItem<V> menuItem)
Removes a menu item from the menu.

menuItem

The menu item to be removed.



Returns:

The current Menu instance.

public Menu<V> removeItemAt(int index)
Removes a menu item from the menu at the specified index.

index

the index of the menu item to be removed.



Returns:

The current Menu instance.

public Menu<V> removeAll()
Removes all items and sub-items from the menu.

Returns:

The current Menu instance.

public Menu<V> appendChild(Separator separator)
Appends a separator to the menu.

separator

The separator to be added.



Returns:

The current Menu instance.

public Menu<V> insertChild(int index, Separator separator)
Inserts a separator to the menu at the specified index, the index should be within the valid range otherwise an exception is thrown.

index

The index to insert the separator at.

separator

The separator to be added.



Returns:

The current Menu instance.

public HTMLDivElement element()
Check super implementation documentation.

Retrieves the main HTMLDivElement element representing this menu.

Returns:

the main HTMLDivElement element.

public void clearSelection(boolean silent)
Clears the current selection of menu items.

silent

if true, does not trigger the deselection listeners; otherwise, does.

public boolean onSearch(String token)
Filters the menu items based on a given search token.

If no results match, a "no results" message is displayed.

token

the string to use for filtering the menu items.



Returns:

true if one or more items match the search token, false otherwise.

public List<AbstractMenuItem<V>> getMenuItems()
Retrieves the list of direct menu items (excluding sub-menu items) contained in this menu.

Returns:

the list of direct menu items.

public List<AbstractMenuItem<V>> getFlatMenuItems()
Retrieves a flattened list of all menu items, including items within groups.

This method will return both direct menu items and those that are part of a MenuItemsGroup .

Returns:

a flattened list of all menu items.

public Menu<V> openSubMenu(Menu<V> dropMenu)
Opens the specified submenu and closes the currently open submenu.

dropMenu

The submenu to open.



Returns:

The current Menu instance.

public Menu<V> getParent()
Retrieves the parent menu of the current menu.

Returns:

The parent menu or null if there isn't any.

public AbstractMenuItem<V> getParentItem()
Retrieves the menu item that acts as the parent for the current menu.

Returns:

The parent menu item or null if there isn't any.

public boolean isSearchable()
Checks if the menu has a search functionality enabled.

Returns:

true if the menu is searchable, false otherwise.

public Menu<V> setSearchable(boolean searchable)
Enables or disables the search functionality within the menu.

searchable

true to enable search, false to disable.



Returns:

The current Menu instance.

API Docs: MenuItem

Constructors

public void MenuItem(String text)
Constructs a menu item with the specified text.

text

the text for the menu item

public void MenuItem(String text, String description)
Constructs a menu item with the specified text and description.

text

the text for the menu item

description

the description for the menu item

Static methods

public static MenuItem<V> create(String text)
Creates a menu item with the specified text.

text

the text for the menu item



Returns:

the created menu item

public static MenuItem<V> create(String text, String description)
Creates a menu item with the specified text and description.

text

the text for the menu item

description

the description for the menu item



Returns:

the created menu item

Public methods

public MenuItem<V> withClickableElement(ChildHandler<MenuItem<V>, AnchorElement> handler)
Applies a custom child handler to the link element of this menu item

handler

The child handler to apply.



Returns:

This menu item instance.

public SmallElement getDescriptionElement()
Retrieves the description element of the menu item.

Returns:

the description element

public SpanElement getTextElement()
Retrieves the text element of the menu item.

Returns:

the text element

public String getText()
@inheritDoc
public boolean onSearch(String token, boolean caseSensitive)
Searches for a given token in the text and description of the menu item.

token

the search token

caseSensitive

indicates if the search should be case-sensitive



Returns:

true if the menu item contains the token, false otherwise

We are a group of passionate people who love what we do

Donate & Support Us