Class Navigation
java.lang.Object
org.patternfly.component.BaseComponent<HTMLElement, Navigation>
org.patternfly.component.navigation.Navigation
- All Implemented Interfaces:
Iterable<NavigationItem>, Attachable, ElementAttributeMethods<HTMLElement, Navigation>, ElementClassListMethods<HTMLElement, Navigation>, ElementConsumerMethods<HTMLElement, Navigation>, ElementContainerMethods<HTMLElement, Navigation>, ElementEventMethods<HTMLElement, Navigation>, ElementIdMethods<HTMLElement, Navigation>, ElementQueryMethods<HTMLElement>, HTMLElementAttributeMethods<HTMLElement, Navigation>, HTMLElementDataMethods<HTMLElement, Navigation>, HTMLElementStyleMethods<HTMLElement, Navigation>, HTMLElementVisibilityMethods<HTMLElement, Navigation>, IsElement<HTMLElement>, TypedBuilder<HTMLElement, Navigation>, Component, HasItems<HTMLElement, Navigation, NavigationItem>
public class Navigation
extends BaseComponent<HTMLElement, Navigation>
implements HasItems<HTMLElement, Navigation, NavigationItem>, Attachable
A navigation organizes an application's structure and content, making it easy to find information and accomplish tasks.
Navigation communicates relationships, context, and actions a user can take within an application.
navigation(primary)
.addItem(navigationItem("itm-1", "Item 1", "#itm-1"))
.addItem(navigationItem("itm-2", "Item 2", "#itm-2"))
.addItem(navigationItem("itm-3", "Item 3", "#itm-3"));
navigation(grouped)
.addGroup(navigationGroup("grp-1", "Group 1")
.addItem(navigationItem("grp-1-itm-1", "Item 1", "#grp-1-itm-1"))
.addItem(navigationItem("grp-1-itm-2", "Item 2", "#grp-1-itm-2"))
.addItem(navigationItem("grp-1-itm-3", "Item 3", "#grp-1-itm-3")))
.addGroup(navigationGroup("grp-2", "Group 2")
.addItem(navigationItem("grp-2-itm-1", "Item 1", "#grp-2-itm-1"))
.addItem(navigationItem("grp-2-itm-2", "Item 2", "#grp-2-itm-2"))
.addDivider()
.addItem(navigationItem("grp-2-itm-3", "Item 3", "#grp-2-itm-3")));
navigation(expandable)
.addItem(navigationItem("itm-1", "Item 1", "#itm-1"))
.addDivider()
.addGroup(expandableNavigationGroup("grp-1", "Group 1")
.addItem(navigationItem("grp-1-itm-1", "Item 1", "#grp-1-itm-1"))
.addItem(navigationItem("grp-1-itm-2", "Item 2", "#grp-1-itm-2"))
.addDivider()
.addItem(navigationItem("grp-1-itm-3", "Item 3", "#grp-1-itm-3")))
.addItem(navigationItem("itm-2", "Item 2", "#itm-2"))
.addItem(navigationItem("itm-3", "Item 3", "#itm-3"))
.addGroup(expandableNavigationGroup("grp-2", "Group 2")
.addItem(navigationItem("grp-2-itm-1", "Item 1", "#grp-2-itm-1"))
.addItem(navigationItem("grp-2-itm-2", "Item 2", "#grp-2-itm-2"))
.addGroup(expandableNavigationGroup("nested-grp-1", "Nested Group")
.addItem(navigationItem("nested-grp-1-itm-1", "Item 1", "#nested-grp-1-itm-1"))
.addDivider()
.addItem(navigationItem("nested-grp-1-itm-2", "Item 2", "#nested-grp-1-itm-2"))));
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionadd(ExpandableNavigationGroup group) add(NavigationGroup group) add(NavigationItem item) Adds an item to the component.addGroup(NavigationGroup group) addItem(NavigationItem item) Adds a single item to the component.<T> NavigationaddItems(Iterable<T> items, Function<T, NavigationItem> display) Adds a collection of items to the component.ariaScrollBackLabel(String label) Aria-label for the back scroll buttonariaScrollForwardLabel(String label) Aria-label for the forward scroll buttonvoidattach(MutationRecord mutationRecord) voidclear()Clears all items from the component.booleanChecks whether the component contains an item associated with the given identifier.voiddetach(MutationRecord mutationRecord) insertGroupAfter(ExpandableNavigationGroup group, String afterIdentifier) insertGroupAfter(NavigationGroup group, String afterIdentifier) insertGroupBefore(ExpandableNavigationGroup group, String beforeIdentifier) insertGroupBefore(NavigationGroup group, String beforeIdentifier) insertItemAfter(NavigationItem item, String afterIdentifier) insertItemBefore(NavigationItem item, String beforeIdentifier) booleanisEmpty()Checks whether the collection of items in the component is empty.Retrieves the item associated with the specified identifier from the component.iterator()static Navigationnavigation(NavigationType type) onAdd(AddItemHandler<Navigation, NavigationItem> onAdd) Registers a callback to be invoked whenever a new item is added to the component.onRemove(RemoveItemHandler<Navigation, NavigationItem> onRemove) Registers a callback to be invoked whenever an item is removed from the component.onSelect(SelectHandler<NavigationItem> selectHandler) onToggle(ToggleHandler<ExpandableNavigationGroup> toggleHandler) onUpdate(UpdateItemHandler<Navigation, NavigationItem> onUpdate) Registers a callback to be invoked whenever an item is updated in the component.voidremoveItem(String identifier) Removes an item from the component based on the provided identifier.voidvoidvoidselect(NavigationItem item) voidselect(NavigationItem item, boolean fireEvent) intsize()Retrieves the total number of items currently contained in the component.that()voidupdateItem(NavigationItem item) Updates an existing item in the component.Methods inherited from class BaseComponent
componentType, element, registerComponentMethods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ElementAttributeMethods
aria, aria, aria, attr, attr, attr, role, roleMethods inherited from interface ElementClassListMethods
classList, classList, css, toggle, toggle, toggleMethods inherited from interface ElementConsumerMethods
apply, runMethods inherited from interface ElementContainerMethods
add, add, add, add, addAll, addAll, addAll, addAll, addAll, addAllMethods inherited from interface ElementEventMethods
on, on, onMethods inherited from interface ElementIdMethods
id, uniqueIdMethods inherited from interface ElementQueryMethods
closest, querySelector, querySelectorAllMethods inherited from interface HasItems
items, replaceItemElement, updateItem, updateItemMethods inherited from interface HTMLElementAttributeMethods
titleMethods inherited from interface HTMLElementDataMethods
data, dataMethods inherited from interface HTMLElementVisibilityMethods
hiddenMethods inherited from interface Iterable
forEach, spliterator
-
Method Details
-
attach
- Specified by:
attachin interfaceAttachable
-
detach
- Specified by:
detachin interfaceAttachable
-
addItems
Description copied from interface:HasItemsAdds a collection of items to the component. The method applies the provided function to each item in the given iterable to transform it into a subcomponent, which is then added to the component.- Specified by:
addItemsin interfaceHasItems<HTMLElement, Navigation, NavigationItem>- Type Parameters:
T- the type of the items in the iterable- Parameters:
items- the iterable collection of items to be addeddisplay- the function used to transform each item into a subcomponent- Returns:
- the builder instance after adding the items
-
addDivider
-
add
-
that
- Specified by:
thatin interfaceTypedBuilder<HTMLElement, Navigation>
-
ariaScrollBackLabel
Aria-label for the back scroll button -
ariaScrollForwardLabel
Aria-label for the forward scroll button -
onAdd
Description copied from interface:HasItemsRegisters a callback to be invoked whenever a new item is added to the component.- Specified by:
onAddin interfaceHasItems<HTMLElement, Navigation, NavigationItem>- Parameters:
onAdd- aAddItemHandlerthat takes the builder instance and the item being added as arguments- Returns:
- the builder instance after adding the callback
-
onRemove
Description copied from interface:HasItemsRegisters a callback to be invoked whenever an item is removed from the component.- Specified by:
onRemovein interfaceHasItems<HTMLElement, Navigation, NavigationItem>- Parameters:
onRemove- aRemoveItemHandlerthat takes the component and the item being removed as arguments- Returns:
- the builder instance after adding the callback
-
onSelect
-
onUpdate
Description copied from interface:HasItemsRegisters a callback to be invoked whenever an item is updated in the component.- Specified by:
onUpdatein interfaceHasItems<HTMLElement, Navigation, NavigationItem>- Parameters:
onUpdate- aUpdateItemHandlerthat takes the component, the previous state of the item, and the updated state of the item as arguments- Returns:
- the builder instance after adding the callback
-
onToggle
-
select
-
select
-
iterator
- Specified by:
iteratorin interfaceIterable<NavigationItem>
-
size
public int size()Description copied from interface:HasItemsRetrieves the total number of items currently contained in the component.- Specified by:
sizein interfaceHasItems<HTMLElement, Navigation, NavigationItem>- Returns:
- the number of items contained in the component
-
isEmpty
public boolean isEmpty()Description copied from interface:HasItemsChecks whether the collection of items in the component is empty.- Specified by:
isEmptyin interfaceHasItems<HTMLElement, Navigation, NavigationItem>- Returns:
trueif the component contains no items;falseotherwise
-
contains
Description copied from interface:HasItemsChecks whether the component contains an item associated with the given identifier.- Specified by:
containsin interfaceHasItems<HTMLElement, Navigation, NavigationItem>- Parameters:
identifier- the identifier of the item to be checked- Returns:
- true if the component contains an item associated with the provided identifier, false otherwise
-
item
Description copied from interface:HasItemsRetrieves the item associated with the specified identifier from the component.- Specified by:
itemin interfaceHasItems<HTMLElement, Navigation, NavigationItem>- Parameters:
identifier- the identifier of the item to be retrieved- Returns:
- the item associated with the given identifier, or
nullif no item is found
-
removeItem
Description copied from interface:HasItemsRemoves an item from the component based on the provided identifier.- Specified by:
removeItemin interfaceHasItems<HTMLElement, Navigation, NavigationItem>- Parameters:
identifier- the identifier of the item to be removed
-
clear
public void clear()Description copied from interface:HasItemsClears all items from the component. This method removes any existing items within the component, leaving it empty. Any associated or registered callbacks related to the removal of items may be invoked as part of this operation.- Specified by:
clearin interfaceHasItems<HTMLElement, Navigation, NavigationItem>