Class Breadcrumbs
- All Implemented Interfaces:
AttachNotifier,DetachNotifier,HasAriaLabel,HasComponentsOfType<BreadcrumbsItem>,HasElement,HasEnabled,HasSize,HasStyle,HasTheme,HasThemeVariant<BreadcrumbsVariant>,Serializable
This component is experimental and needs to be enabled with the
com.vaadin.experimental.breadcrumbsComponent feature flag.
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe internationalization properties forBreadcrumbs.static enumThe mode that determines how the breadcrumb trail is populated. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new breadcrumbs component inBreadcrumbs.Mode.ROUTERmode.Breadcrumbs(Breadcrumbs.Mode mode) Creates a new breadcrumbs component in the given mode. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(BreadcrumbsItem... components) Adds the given components as children of this component.voidadd(Collection<BreadcrumbsItem> components) Adds the given components as children of this component.voidaddComponentAsFirst(BreadcrumbsItem component) Adds the given component as the first child of this component.voidaddComponentAtIndex(int index, BreadcrumbsItem component) Adds the given component as a child of this component at the specific index.bindChildren(Signal<List<S>> list, SerializableFunction<S, BreadcrumbsItem> childFactory) Binds a listSignalto this component using a child component factory.getI18n()Gets the internationalization object previously set for this component.getMode()Gets the mode that determines how the breadcrumb trail is populated.protected voidonAttach(AttachEvent attachEvent) Called when the component is attached to a UI.protected voidonDetach(DetachEvent detachEvent) Called when the component is detached from a UI.voidremove(BreadcrumbsItem... components) Removes the given child components from this component.voidremove(Collection<BreadcrumbsItem> components) Removes the given child components from this component.voidRemoves all contents from this component, including child components, text content as well as child elements that have been added directly to this component using theElementAPI.voidreplace(BreadcrumbsItem oldComponent, BreadcrumbsItem newComponent) Replaces the component in the container with another one without changing position.voidSets the internationalization properties for this component.voidsetMode(Breadcrumbs.Mode newMode) Sets the mode that determines how the breadcrumb trail is populated.Methods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasAriaLabel
getAriaLabel, getAriaLabelledBy, setAriaLabel, setAriaLabelledBy, setAriaLabelledByMethods inherited from interface com.vaadin.flow.component.HasComponentsOfType
getChildren, getComponentAt, getComponentCount, indexOfMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasSize
bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, bindThemeName, bindThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, bindThemeVariant, bindThemeVariants, removeThemeVariants, setThemeVariant, setThemeVariants, setThemeVariants
-
Constructor Details
-
Breadcrumbs
public Breadcrumbs()Creates a new breadcrumbs component inBreadcrumbs.Mode.ROUTERmode. -
Breadcrumbs
Creates a new breadcrumbs component in the given mode.- Parameters:
mode- the mode that determines how the trail is populated, notnull
-
-
Method Details
-
getMode
Gets the mode that determines how the breadcrumb trail is populated.- Returns:
- the current mode
-
setMode
Sets the mode that determines how the breadcrumb trail is populated.Switching to a different mode discards the existing children: both the
ROUTER -> MANUALandMANUAL -> ROUTERtransitions clear the current trail so the new mode can start fresh. Setting the mode to its current value is a no-op and leaves the children untouched.- Parameters:
newMode- the mode that determines how the trail is populated, notnull- Throws:
IllegalStateException- if a children binding set viabindChildrenis active; such a binding takes over the trail and cannot be handed back to component-controlled population
-
add
Description copied from interface:HasComponentsOfTypeAdds the given components as children of this component.In case any of the specified components has already been added to another parent, it will be removed from there and added to this one.
- Specified by:
addin interfaceHasComponentsOfType<BreadcrumbsItem>- Parameters:
components- the components to add
-
add
Description copied from interface:HasComponentsOfTypeAdds the given components as children of this component.In case any of the specified components has already been added to another parent, it will be removed from there and added to this one.
- Specified by:
addin interfaceHasComponentsOfType<BreadcrumbsItem>- Parameters:
components- the components to add
-
remove
Description copied from interface:HasComponentsOfTypeRemoves the given child components from this component.- Specified by:
removein interfaceHasComponentsOfType<BreadcrumbsItem>- Parameters:
components- the components to remove
-
remove
Description copied from interface:HasComponentsOfTypeRemoves the given child components from this component.- Specified by:
removein interfaceHasComponentsOfType<BreadcrumbsItem>- Parameters:
components- the components to remove
-
removeAll
public void removeAll()Description copied from interface:HasComponentsOfTypeRemoves all contents from this component, including child components, text content as well as child elements that have been added directly to this component using theElementAPI. It also removes the children added only at the client-side.- Specified by:
removeAllin interfaceHasComponentsOfType<BreadcrumbsItem>
-
addComponentAsFirst
Description copied from interface:HasComponentsOfTypeAdds the given component as the first child of this component.In case the specified component has already been added to another parent, it will be removed from there and added to this one.
- Specified by:
addComponentAsFirstin interfaceHasComponentsOfType<BreadcrumbsItem>- Parameters:
component- the component to add, value should not be null
-
addComponentAtIndex
Description copied from interface:HasComponentsOfTypeAdds the given component as a child of this component at the specific index.In case the specified component has already been added to another parent, it will be removed from there and added to this one.
- Specified by:
addComponentAtIndexin interfaceHasComponentsOfType<BreadcrumbsItem>- Parameters:
index- the index, where the component will be added. The index must be non-negative and may not exceed the children countcomponent- the component to add, value should not be null
-
replace
Description copied from interface:HasComponentsOfTypeReplaces the component in the container with another one without changing position. This method replaces a component with another one is such a way that the new component overtakes the position of the old component. If the old component is not in the container, the new component is added to the container. If both components are already in the container, their positions are swapped. Component attach and detach events should be taken care as with add and remove.- Specified by:
replacein interfaceHasComponentsOfType<BreadcrumbsItem>- Parameters:
oldComponent- the old component that will be replaced. Can benull, which will make the newComponent to be added to the layout without replacing any othernewComponent- the new component to be replaced. Can benull, which will make the oldComponent to be removed from the layout without adding any other
-
bindChildren
public <V extends @Nullable Object,S extends Signal<V>> void bindChildren(Signal<List<S>> list, SerializableFunction<S, BreadcrumbsItem> childFactory) Description copied from interface:HasComponentsOfTypeBinds a listSignalto this component using a child component factory. Each itemSignalin the list corresponds to a child component within this component.This component is automatically updated to reflect the structure of the list. Changes to the list, such as additions, removals, or reordering, will update this component's children accordingly.
This component must not contain any children in the default slot (i.e. without a
slotattribute) that are not part of the list. If this component has existing default-slot children when this method is called, or if it contains unrelated default-slot children after the list changes, anIllegalStateExceptionwill be thrown. Named-slot children are allowed and can be added or removed freely while the binding is active.New child components are created using the provided
childFactoryfunction. This function takes aSignalfrom the list and returns a corresponding child component. It shouldn't returnnull. TheSignalcan be further bound to the returned component as needed. Note thatchildFactoryis run inside aEffect, and thereforeSignal.get()calls makes effect re-run automatically on signal value change.Example of usage:
SharedListSignal<String> taskList = new SharedListSignal<>(String.class); UnorderedList component = new UnorderedList(); component.bindChildren(taskList, ListItem::new);
Note: The default implementation adds children directly to the component?s element using the Element API and does not invoke
HasComponentsOfType.add(Component...). Components that overrideaddor manage children indirectly must override this method to provide a suitable implementation or explicitly disable it.- Specified by:
bindChildrenin interfaceHasComponentsOfType<BreadcrumbsItem>- Type Parameters:
V- the value type of theSignals in the listS- the type of theSignals in the list- Parameters:
list- list signal to bind to the parent, must not benullchildFactory- factory to create new component, must not benull
-
onAttach
Description copied from class:ComponentCalled when the component is attached to a UI.This method is invoked before the
AttachEventis fired for the component. Make sure to callsuper.onAttachwhen overriding this method. -
onDetach
Description copied from class:ComponentCalled when the component is detached from a UI.This method is invoked before the
DetachEventis fired for the component.Make sure to call
super.onDetachwhen overriding this method. -
getI18n
Gets the internationalization object previously set for this component.NOTE: Updating the instance that is returned from this method will not update the component if not set again using
setI18n(BreadcrumbsI18n)- Returns:
- the i18n object or
nullif no i18n object has been set
-
setI18n
Sets the internationalization properties for this component.- Parameters:
i18n- the i18n object, notnull
-