Class Navigation
In-app navigation API on top of the declarative @Route table.
Navigation is the imperative counterpart to the Route annotation:
declare your forms with @Route("/users/:id") once, then trigger
navigation from anywhere with Navigation.navigate("/users/42"). The same
route table that handles deep links is reused, so there is exactly one
place that knows how /users/:id maps to a form.
The class also exposes the navigation stack so applications can render breadcrumb UIs without maintaining a parallel history:
Container breadcrumbs = new Container(BoxLayout.x());
for (final NavigationEntry e : Navigation.getStack()) {
Button crumb = new Button(e.getTitle());
crumb.addActionListener(evt -> Navigation.popTo(e));
breadcrumbs.add(crumb);
}
The surface is intentionally tiny -- five static methods and one value
type. Applications that prefer raw Form#show / Form#showBack keep
working unchanged; the Navigation stack only records URL-driven
navigations.
All methods must be called on the EDT.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanback()Pop the top entry off the navigation stack and return to the previous one.static booleanDispatch a URL delivered by the platform.static NavigationEntryThe current entry (top of stack), or null when the stack is empty.static List<NavigationEntry> getStack()Unmodifiable snapshot of the navigation stack, oldest entry first (breadcrumb order).static booleanNavigate to a path.static booleanpopTo(NavigationEntry entry) Pop entries untilentryis on top, then show its form viaForm#showBack.static booleanrestoreStack(List<String> paths) Rebuilds the stack from a list of paths, showing only the last one.static voidInstalls the build-time-generated route dispatcher.
-
Method Details
-
setDispatcher
Installs the build-time-generated route dispatcher. Invoked once bycom.codename1.router.generated.Routes#bootstrapduring framework initialization. Application code should not call this. -
back
public static boolean back()Pop the top entry off the navigation stack and return to the previous one. UsesForm#showBackso the transition runs in reverse. Returnstruewhen a frame was popped,falsewhen the stack had at most one entry (already at the root, nothing to go back to). -
getCurrent
The current entry (top of stack), or null when the stack is empty. -
getStack
Unmodifiable snapshot of the navigation stack, oldest entry first (breadcrumb order). The list is a copy: mutating navigations after the call do not affect it. -
restoreStack
Rebuilds the stack from a list of paths, showing only the last one.
This is how
com.codename1.continuity.Continuityputs the user back where they were: the saved state is a list of paths, and every one of them has to become a stack frame orback()would land on a screen that was never built. Replaying them withnavigatewould work and would also flash every intermediate screen past the user with a transition each, so the frames are built silently and only the top one is shown.Paths that no longer match a route are skipped rather than failing the restore. A rebuilt app legitimately drops routes, and refusing to restore anything because one deep frame went away would lose the whole session over a screen the user was not on.
Replaces whatever was on the stack. Must be called on the EDT.
Parameters
paths: the paths, oldest first
Returns
true when at least one frame was rebuilt and shown
-
dispatchExternalUrl
Dispatch a URL delivered by the platform. Invoked bycom.codename1.ui.Display#setProperty(String, String)for URL-shapedAppArgvalues; applications should call#navigate(String)instead.
-