Class BreadcrumbsItem
- All Implemented Interfaces:
AttachNotifier,DetachNotifier,HasElement,HasEnabled,HasStyle,HasText,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
HasText.WhiteSpace -
Constructor Summary
ConstructorsConstructorDescriptionBreadcrumbsItem(String text) Creates a breadcrumbs item with the given text and no path.BreadcrumbsItem(String text, Class<? extends Component> view) Creates a breadcrumbs item with the given text that links to the given view.BreadcrumbsItem(String text, Class<? extends Component> view, 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 Component> view, 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 Component> view, RouteParameters params, 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, 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 TypeMethodDescriptionBinds aSignal's value to the text content of this component.getPath()Gets the path this item links to.getText()Gets the text content of this component.voidResolves the URL of the given view via the Vaadin router and sets it as the path this item links to.voidsetPath(Class<? extends Component> view, 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
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
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
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 Component> view, RouteParameters params, 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.
-
getText
Description copied from interface:HasTextGets the text content of this component. This method only considers the text of the actual component. The text contents of any child components or elements are not considered. -
bindText
Description copied from interface:HasTextBinds aSignal's value to the text content of this component. The text content is set immediately with the current signal value when the binding is created, and is kept synchronized with any subsequent signal value changes while the element is in attached state. When the element is in detached state, signal value changes have no effect.nullsignal unbinds the existing binding.While a Signal is bound, any attempt to set the text content manually throws
BindingActiveException. Same happens when trying to bind a new Signal while one is already bound.Example of usage:
ValueSignal<String> signal = new ValueSignal<>(""); Span component = new Span(""); add(component); component.bindText(signal); signal.set("text"); // The component text content is set to "text" -
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
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:
-