Class Router

java.lang.Object
org.fulib.fx.controller.Router

@Singleton public class Router extends Object
  • Constructor Details

    • Router

      @Inject public Router()
  • Method Details

    • registerRoutes

      public void registerRoutes(@NotNull @NotNull Object routes)
      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 with the given route.
      Parameters:
      route - The route of the controller
      parameters - 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

      public Object getController(String route)
      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

      public void addToHistory(javafx.util.Pair<Either<TraversableNodeTree.Node<Field>,Object>,Map<String,Object>> pair)
    • back

      public javafx.util.Pair<Object,javafx.scene.Parent> back()
      Goes back to the previous controller in the history.
      Returns:
      The rendered controller
    • forward

      public javafx.util.Pair<Object,javafx.scene.Parent> forward()
      Goes forward to the next controller in the history.
      Returns:
      The rendered controller
    • current

      public javafx.util.Pair<Object,Map<String,Object>> 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