Create a navigation component with multiple pages to create a multipage app.
Call Jt.navigation in your entrypoint app class to define the available pages in your app.
Jt.navigation use() returns the current page.
When using Jt.navigation, your entrypoint app class acts like a frame of common elements around each of your pages.
The set of available pages can be updated with each rerun for dynamic navigation.
By default, Jt.navigation displays the available pages in the sidebar if there is more than one page.
This behavior can be changed using the position builder method.
| Method Signatures and Parameters | |
Jt.navigation(JtPage.Builder[] pages) | pages (io.javelit.core.JtPage.Builder[]) The pages to include in the navigation |
| Returns after .use() | |
(io.javelit.core.NavigationComponent.Builder) | The current io.javelit.core.NavigationComponent.Builder value of the component. |
Examples
Basic multipage navigation setup
import io.javelit.core.Jt;
public class NavigationApp {
public static void page1() {
Jt.title("First Page").use();
}
public static void page2() {
Jt.title("Second Page").use();
}
public static void main(String[] args) {
var page = Jt.navigation(
Jt.page("page1", NavigationApp::page1).title("First page").icon("🔥"),
Jt.page("page2", NavigationApp::page2).title("Second page").icon(":favorite:"))
.use();
page.run();
}
}
Still have questions?
Go to our discussions forum for helpful information and advice from Javelit experts.