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
ConstructorDescriptionCreates 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 TypeMethodDescriptionvoid
Callback executed after navigation has been executed.Gets theHighlightAction
of this link.Gets theHighlightCondition
of this link.getHref()
Gets the href (the URL) of this link.Gets theQueryParameters
of this link.void
setHighlightAction
(HighlightAction<RouterLink> highlightAction) Sets theHighlightAction
of this link, which will be performed with the evaluation of this link'sHighlightCondition
.void
setHighlightCondition
(HighlightCondition<RouterLink> highlightCondition) Sets theHighlightCondition
of this link, which determines if the link should be highlighted when aAfterNavigationEvent
occurs.void
setQueryParameters
(QueryParameters queryParameters) Sets theQueryParameters
of this link.<T,
C extends Component & HasUrlParameter<T>>
voidSet the navigation target for this link.void
Set the navigation target for this link.void
setRoute
(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.void
Set the navigation target for this link.void
setRoute
(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, setVisible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
Methods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListener
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
Methods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, getTabIndex, setTabIndex
Methods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListener
Methods inherited from interface com.vaadin.flow.component.HasComponents
add, add, add, addComponentAsFirst, addComponentAtIndex, remove, remove, removeAll
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
Methods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabled
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
Methods 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 theQueryParameters
of this link.- Returns:
- an optional of
QueryParameters
, or an empty optional if there are no query parameters set - See Also:
-
setQueryParameters
Sets theQueryParameters
of this link.The query string will be generated from
QueryParameters.getQueryString()
and will be appended to thehref
attribute of this link.- Parameters:
queryParameters
- the query parameters object, ornull
to remove existing query parameters
-
getHighlightCondition
Gets theHighlightCondition
of 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 theHighlightCondition
of this link, which determines if the link should be highlighted when aAfterNavigationEvent
occurs.The evaluation of this condition will be processed by this link's
HighlightAction
.- Parameters:
highlightCondition
- the highlight condition, notnull
- See Also:
-
getHighlightAction
Gets theHighlightAction
of this link.The default action is to toggle the
highlight
attribute of the element, as defined inHighlightActions.toggleAttribute(String)
.- Returns:
- the highlight action, never
null
- See Also:
-
setHighlightAction
Sets theHighlightAction
of this link, which will be performed with the evaluation of this link'sHighlightCondition
.The old action will be executed passing
false
toHighlightAction.highlight(Object, boolean)
to clear any previous highlight state.- Parameters:
highlightAction
- the highlight action, notnull
- See Also:
-