Interface RouteParentResolver
- All Superinterfaces:
Serializable
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
This is the dynamic counterpart of a static RouteParent.value(). The
logical parent it returns is used to build navigation hierarchies, such as
breadcrumb trails, where the whole chain of ancestor routes needs to be known
without instantiating any of them. It mirrors PageTitleGenerator: the
parent is resolved purely from the navigation target class and its
RouteParameters.
A resolver is referenced from a route through RouteParent.resolver():
@Route("orgs/:orgId/projects/:projectId")
@RouteParent(resolver = OrgParentResolver.class)
public class ProjectView extends Div {
// ...
}
public class OrgParentResolver implements RouteParentResolver {
@Override
public Optional<RouteReference> resolveParent(
RouteParentContext context) {
// carry over only the parameters the parent route needs
RouteParameters parentParameters = new RouteParameters("orgId",
context.routeParameters().get("orgId").orElseThrow());
return Optional
.of(new RouteReference(OrgView.class, parentParameters));
}
}
Returning an empty Optional marks the top of the hierarchy.
Implementations must be stateless and are expected to be cheap to create:
they are instantiated through the application Instantiator (so
dependency injection is available) every time a parent is resolved, never the
route itself.
- Since:
- 25.2
- Author:
- Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptionresolveParent(RouteParentContext context) Resolves the logical parent of the route described by the given context.
-
Method Details
-
resolveParent
Resolves the logical parent of the route described by the given context.The returned reference carries both the parent navigation target and the
RouteParametersit should be resolved with. The resolver is responsible for mapping the child route parameters to the subset the parent route expects.- Parameters:
context- the context describing the route whose parent is resolved and its route parameters, notnull- Returns:
- the logical parent reference, or an empty
Optionalif the route has no logical parent (it is a hierarchy root)
-