Package org.fulib.fx.controller
Class Router
java.lang.Object
org.fulib.fx.controller.Router
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToHistory(javafx.util.Pair<Either<TraversableNodeTree.Node<Field>, Object>, Map<String, Object>> pair) javafx.util.Pair<Object,javafx.scene.Node> back()Goes back to the previous controller in the history.current()Returns the current field and its parameters.javafx.util.Pair<Object,javafx.scene.Node> forward()Goes forward to the next controller in the history.getController(String route) Returns the controller with the given route without initializing and rendering it.voidregisterRoutes(@NotNull Object routes) Registers all routes in the given class.@NotNull javafx.util.Pair<Object,javafx.scene.Parent> renderRoute(@NotNull String route, @NotNull Map<@NotNull String, @Nullable Object> parameters) Initializes and renders the controller/component with the given route.voidsetHistorySize(int size) Updates the history size.
-
Constructor Details
-
Router
@Inject public Router()
-
-
Method Details
-
registerRoutes
Registers all routes in the given class.- Parameters:
routes- The class to register the routes from
-
renderRoute
@NotNull public @NotNull javafx.util.Pair<Object,javafx.scene.Parent> renderRoute(@NotNull @NotNull String route, @NotNull @NotNull Map<@NotNull String, @Nullable Object> parameters) Initializes and renders the controller/component with the given route. This only works for controllers and components having a parent as their root node.- Parameters:
route- The route of the controllerparameters- The parameters to pass to the controller- Returns:
- A pair containing the controller instance and the rendered parent (will be the same if the controller is a component)
- Throws:
ControllerInvalidRouteException- If the route couldn't be found
-
getController
Returns the controller with the given route without initializing and rendering it. The route will be seen as absolute, meaning it will be treated as a full path.- Parameters:
route- The route of the controller- Returns:
- The controller instance
-
addToHistory
-
back
Goes back to the previous controller in the history.- Returns:
- The rendered controller
-
forward
Goes forward to the next controller in the history.- Returns:
- The rendered controller
-
current
Returns the current field and its parameters. This is used internally for reloading the current controller.- Returns:
- The current controller object and its parameters
-
setHistorySize
public void setHistorySize(int size) Updates the history size. Setting the size to 1 will disable the history except for the current controller which will be stored for reloading.- Parameters:
size- The size of the history
-