Class RouterLink
- All Implemented Interfaces:
AttachNotifier,BlurNotifier<RouterLink>,DetachNotifier,Focusable<RouterLink>,FocusNotifier<RouterLink>,HasComponents,HasElement,HasEnabled,HasStyle,HasText,AfterNavigationObserver,AfterNavigationHandler,Serializable
Router instead of
loading a new page in the browser.
The href attribute of Component.getElement() will only be
up-to-date when the component is attached to a UI.
- Since:
- 1.0
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
BlurNotifier.BlurEvent<C extends Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
FocusNotifier.FocusEvent<C extends Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasText
HasText.WhiteSpace -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new empty router link.RouterLink(Router router, Class<? extends C> navigationTarget, T parameter) Creates a new router link for the given navigation target using the given parameter.RouterLink(Router router, Class<? extends Component> navigationTarget) Creates a new router link for the given navigation target.RouterLink(Router router, Class<? extends Component> navigationTarget, RouteParameters parameters) Creates a new router link for the given navigation target using the given parameters.RouterLink(Router router, String text, Class<? extends C> navigationTarget, T parameter) Creates a new router link for the given navigation target using the given text and parameter.RouterLink(Router router, String text, Class<? extends Component> navigationTarget) Creates a new router link for the given navigation target using the given text.RouterLink(Router router, String text, Class<? extends Component> navigationTarget, RouteParameters parameters) Creates a new router link for the given navigation target using the given text and parameters.RouterLink(Class<? extends C> navigationTarget, T parameter) Creates a new router link for the given navigation target using the given parameter.RouterLink(Class<? extends Component> navigationTarget) Creates a new router link for the given navigation target.RouterLink(Class<? extends Component> navigationTarget, RouteParameters parameters) Creates a new router link for the given navigation target using the given parameters.RouterLink(String text, Class<? extends C> navigationTarget, T parameter) Creates a new router link for the given navigation target using the given text and parameter.RouterLink(String text, Class<? extends Component> navigationTarget) Creates a new router link for the given navigation target using the given text.RouterLink(String text, Class<? extends Component> navigationTarget, RouteParameters parameters) Creates a new router link for the given navigation target using the given text and parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoidCallback executed after navigation has been executed.Gets theHighlightActionof this link.Gets theHighlightConditionof this link.getHref()Gets the href (the URL) of this link.Gets theQueryParametersof this link.voidsetHighlightAction(HighlightAction<RouterLink> highlightAction) Sets theHighlightActionof this link, which will be performed with the evaluation of this link'sHighlightCondition.voidsetHighlightCondition(HighlightCondition<RouterLink> highlightCondition) Sets theHighlightConditionof this link, which determines if the link should be highlighted when aAfterNavigationEventoccurs.voidsetQueryParameters(QueryParameters queryParameters) Sets theQueryParametersof this link.<T,C extends Component & HasUrlParameter<T>>
voidSet the navigation target for this link.voidSet the navigation target for this link.voidsetRoute(Router router, Class<? extends Component> navigationTarget, RouteParameters parameters) Set the navigation target for this link.<T,C extends Component & HasUrlParameter<T>>
voidSet the navigation target for this link.voidSet the navigation target for this link.voidsetRoute(Class<? extends Component> navigationTarget, RouteParameters parameters) Set the navigation target for this link.Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, 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.BlurNotifier
addBlurListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.component.HasComponents
add, add, add, addComponentAsFirst, addComponentAtIndex, remove, remove, removeAllMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasText
getText, getWhiteSpace, setText, setWhiteSpace
-
Constructor Details
-
RouterLink
public RouterLink()Creates a new empty router link. -
RouterLink
Creates a new router link for the given navigation target.- Parameters:
navigationTarget- navigation target
-
RouterLink
Creates a new router link for the given navigation target using the given text.- Parameters:
text- link textnavigationTarget- navigation target
-
RouterLink
Creates a new router link for the given navigation target using the given parameter.- Type Parameters:
T- url parameter typeC- navigation target type- Parameters:
navigationTarget- navigation targetparameter- url parameter for navigation target
-
RouterLink
Creates a new router link for the given navigation target using the given text and parameter.- Type Parameters:
T- url parameter typeC- navigation target type- Parameters:
text- link textnavigationTarget- navigation targetparameter- url parameter for navigation target
-
RouterLink
Creates a new router link for the given navigation target using the given parameters.- Parameters:
navigationTarget- navigation targetparameters- route parameters for navigation target
-
RouterLink
public RouterLink(String text, Class<? extends Component> navigationTarget, RouteParameters parameters) Creates a new router link for the given navigation target using the given text and parameters.- Parameters:
text- link textnavigationTarget- navigation targetparameters- route parameters for navigation target
-
RouterLink
public RouterLink(Router router, Class<? extends Component> navigationTarget) throws IllegalArgumentException Creates a new router link for the given navigation target.- Parameters:
router- router used for navigationnavigationTarget- navigation target- Throws:
IllegalArgumentException- if navigation target requires parameters
-
RouterLink
public RouterLink(Router router, String text, Class<? extends Component> navigationTarget) throws IllegalArgumentException Creates a new router link for the given navigation target using the given text.- Parameters:
router- router used for navigationtext- link textnavigationTarget- navigation target- Throws:
IllegalArgumentException- if navigation target requires parameters
-
RouterLink
Creates a new router link for the given navigation target using the given parameter.- Type Parameters:
T- url parameter typeC- navigation target type- Parameters:
router- router used for navigationnavigationTarget- navigation targetparameter- url parameter for navigation target
-
RouterLink
Creates a new router link for the given navigation target using the given text and parameter.- Type Parameters:
T- url parameter typeC- navigation target type- Parameters:
router- router used for navigationtext- link textnavigationTarget- navigation targetparameter- url parameter for navigation target
-
RouterLink
public RouterLink(Router router, Class<? extends Component> navigationTarget, RouteParameters parameters) Creates a new router link for the given navigation target using the given parameters.- Parameters:
router- router used for navigationnavigationTarget- navigation targetparameters- route parameters for navigation target
-
RouterLink
public RouterLink(Router router, String text, Class<? extends Component> navigationTarget, RouteParameters parameters) Creates a new router link for the given navigation target using the given text and parameters.- Parameters:
router- router used for navigationtext- link textnavigationTarget- navigation targetparameters- route parameters for navigation target
-
-
Method Details
-
setRoute
Set the navigation target for this link.- Parameters:
router- router used for navigationnavigationTarget- navigation target- Throws:
IllegalArgumentException- if navigation target requires parameters
-
setRoute
public <T,C extends Component & HasUrlParameter<T>> void setRoute(Router router, Class<? extends C> navigationTarget, T parameter) Set the navigation target for this link.- Type Parameters:
T- url parameter typeC- navigation target type- Parameters:
router- router used for navigationnavigationTarget- navigation targetparameter- url parameter for navigation target
-
setRoute
public void setRoute(Router router, Class<? extends Component> navigationTarget, RouteParameters parameters) Set the navigation target for this link.- Parameters:
router- router used for navigationnavigationTarget- navigation targetparameters- route parameters for navigation target
-
setRoute
Set the navigation target for this link.- Parameters:
navigationTarget- navigation target- Throws:
IllegalArgumentException- if navigation target requires parameters
-
setRoute
public <T,C extends Component & HasUrlParameter<T>> void setRoute(Class<? extends C> navigationTarget, T parameter) Set the navigation target for this link.- Type Parameters:
T- url parameter typeC- navigation target type- Parameters:
navigationTarget- navigation targetparameter- url parameter for navigation target
-
setRoute
Set the navigation target for this link.- Parameters:
navigationTarget- navigation targetparameters- route parameters for navigation target
-
getHref
Gets the href (the URL) of this link.- Returns:
- the href
-
getQueryParameters
Gets theQueryParametersof this link.- Returns:
- an optional of
QueryParameters, or an empty optional if there are no query parameters set - See Also:
-
setQueryParameters
Sets theQueryParametersof this link.The query string will be generated from
QueryParameters.getQueryString()and will be appended to thehrefattribute of this link.- Parameters:
queryParameters- the query parameters object, ornullto remove existing query parameters
-
getHighlightCondition
Gets theHighlightConditionof this link.The default condition is to checked whether the current location starts with this link's
getHref()value, as defined inHighlightConditions.locationPrefix().- Returns:
- the highlight condition, never
null - See Also:
-
setHighlightCondition
Sets theHighlightConditionof this link, which determines if the link should be highlighted when aAfterNavigationEventoccurs.The evaluation of this condition will be processed by this link's
HighlightAction.- Parameters:
highlightCondition- the highlight condition, notnull- See Also:
-
getHighlightAction
Gets theHighlightActionof this link.The default action is to toggle the
highlightattribute of the element, as defined inHighlightActions.toggleAttribute(String).- Returns:
- the highlight action, never
null - See Also:
-
setHighlightAction
Sets theHighlightActionof this link, which will be performed with the evaluation of this link'sHighlightCondition.The old action will be executed passing
falsetoHighlightAction.highlight(Object, boolean)to clear any previous highlight state.- Parameters:
highlightAction- the highlight action, notnull- See Also:
-