Class BreadcrumbsItem
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasText,com.vaadin.flow.component.shared.HasPrefix,Serializable
Breadcrumbs component, representing a single entry in
the navigation trail.
An item carries the text shown in the trail and, optionally, a path
it links to. An item without a path is the current page and is rendered as a
non-link. The link target can be set as a plain URL string via
setPath(String) or resolved from a Flow route class via
setPath(Class) / setPath(Class, RouteParameters). An
optional prefix component (typically an icon) can be shown before the text.
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasText
com.vaadin.flow.component.HasText.WhiteSpace -
Constructor Summary
ConstructorsConstructorDescriptionBreadcrumbsItem(String text) Creates a breadcrumbs item with the given text and no path.BreadcrumbsItem(String text, Class<? extends com.vaadin.flow.component.Component> view) Creates a breadcrumbs item with the given text that links to the given view.BreadcrumbsItem(String text, Class<? extends com.vaadin.flow.component.Component> view, com.vaadin.flow.component.Component prefixComponent) Creates a breadcrumbs item with the given text and prefix component (like an icon) that links to the given view.BreadcrumbsItem(String text, Class<? extends com.vaadin.flow.component.Component> view, com.vaadin.flow.router.RouteParameters params) Creates a breadcrumbs item with the given text that links to the given view using the given route parameters.BreadcrumbsItem(String text, Class<? extends com.vaadin.flow.component.Component> view, com.vaadin.flow.router.RouteParameters params, com.vaadin.flow.component.Component prefixComponent) Creates a breadcrumbs item with the given text and prefix component (like an icon) that links to the given view using the given route parameters.BreadcrumbsItem(String text, String path) Creates a breadcrumbs item with the given text that links to the given path.BreadcrumbsItem(String text, String path, com.vaadin.flow.component.Component prefixComponent) Creates a breadcrumbs item with the given text and prefix component (like an icon) that links to the given path. -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.dom.SignalBinding<String> getPath()Gets the path this item links to.getText()voidResolves the URL of the given view via the Vaadin router and sets it as the path this item links to.voidsetPath(Class<? extends com.vaadin.flow.component.Component> view, com.vaadin.flow.router.RouteParameters parameters) Resolves the URL of the given view via the Vaadin router using the given route parameters and sets it as the path this item links to.voidSets the path, as a URL string, this item links to.voidSets the given string as the text content of this item.voidsetUnsafePath(String path) Sets the path this item links to without validating its scheme.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, onAttach, onDetach, 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.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.shared.HasPrefix
getPrefixComponent, setPrefixComponentMethods 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.HasText
getWhiteSpace, setWhiteSpace
-
Constructor Details
-
BreadcrumbsItem
Creates a breadcrumbs item with the given text and no path. An item without a path represents the current page and is rendered as a non-link.- Parameters:
text- the text of the item
-
BreadcrumbsItem
Creates a breadcrumbs item with the given text that links to the given path.- Parameters:
text- the text of the itempath- the path to link to- Throws:
IllegalArgumentException- ifpathuses a scheme that is not considered safe; seesetUnsafePath(String)and the "com.vaadin.safeUrlSchemes" configuration property
-
BreadcrumbsItem
Creates a breadcrumbs item with the given text that links to the given view.- Parameters:
text- the text of the itemview- the view to link to
-
BreadcrumbsItem
public BreadcrumbsItem(String text, Class<? extends com.vaadin.flow.component.Component> view, com.vaadin.flow.router.RouteParameters params) Creates a breadcrumbs item with the given text that links to the given view using the given route parameters.- Parameters:
text- the text of the itemview- the view to link toparams- the route parameters
-
BreadcrumbsItem
public BreadcrumbsItem(String text, String path, com.vaadin.flow.component.Component prefixComponent) Creates a breadcrumbs item with the given text and prefix component (like an icon) that links to the given path.- Parameters:
text- the text of the itempath- the path to link toprefixComponent- the prefix component for the item (usually an icon)- Throws:
IllegalArgumentException- ifpathuses a scheme that is not considered safe; seesetUnsafePath(String)and the "com.vaadin.safeUrlSchemes" configuration property
-
BreadcrumbsItem
public BreadcrumbsItem(String text, Class<? extends com.vaadin.flow.component.Component> view, com.vaadin.flow.component.Component prefixComponent) Creates a breadcrumbs item with the given text and prefix component (like an icon) that links to the given view.- Parameters:
text- the text of the itemview- the view to link toprefixComponent- the prefix component for the item (usually an icon)
-
BreadcrumbsItem
public BreadcrumbsItem(String text, Class<? extends com.vaadin.flow.component.Component> view, com.vaadin.flow.router.RouteParameters params, com.vaadin.flow.component.Component prefixComponent) Creates a breadcrumbs item with the given text and prefix component (like an icon) that links to the given view using the given route parameters.- Parameters:
text- the text of the itemview- the view to link toparams- the route parametersprefixComponent- the prefix component for the item (usually an icon)
-
-
Method Details
-
setText
Sets the given string as the text content of this item.This method removes any existing content in the default slot and replaces it with the given text. Other slotted children (such as the prefix) are preserved.
- Specified by:
setTextin interfacecom.vaadin.flow.component.HasText- Parameters:
text- the text content to set, ornullto remove existing text
-
getText
- Specified by:
getTextin interfacecom.vaadin.flow.component.HasText
-
bindText
public com.vaadin.flow.dom.SignalBinding<String> bindText(com.vaadin.flow.signals.Signal<String> textSignal) - Specified by:
bindTextin interfacecom.vaadin.flow.component.HasText
-
getPath
Gets the path this item links to.- Returns:
- the path this item links to, or
nullif the item has no path
-
setPath
Sets the path, as a URL string, this item links to.Note that there is also an alternative way of setting the link path via
setPath(Class).- Parameters:
path- the path to link to, ornullto remove the path and render the item as the current page (a non-link)- See Also:
-
setUnsafePath
Sets the path this item links to without validating its scheme.Unlike
setPath(String), this method does not reject paths based on the "com.vaadin.safeUrlSchemes" configuration. Use it only for paths that are fully under your control and known to be safe, such as a hard-codedjavascript:URL. Passing untrusted input here can expose the application to cross-site scripting (XSS) attacks.- Parameters:
path- the path to link to, ornullto remove the path and render the item as the current page (a non-link)- See Also:
-
setPath
Resolves the URL of the given view via the Vaadin router and sets it as the path this item links to.- Parameters:
view- the view to link to. The view should be annotated with theRouteannotation. Set tonullto remove the path.- See Also:
-
setPath
public void setPath(Class<? extends com.vaadin.flow.component.Component> view, com.vaadin.flow.router.RouteParameters parameters) Resolves the URL of the given view via the Vaadin router using the given route parameters and sets it as the path this item links to.- Parameters:
view- the view to link to. The view should be annotated with theRouteannotation. Set tonullto remove the path.parameters- the route parameters- See Also:
-