Class HTMLTemplateRoute

All Implemented Interfaces:
spark.Route
Direct Known Subclasses:
Account, Docs, ER, Games, Horses, Interfaces, Login, Register, Requirements, ResetPassword, RiskAnalysis, Root, Roulette, Structure, SystemArchitecture, TechStack, Tests, UML

public abstract class HTMLTemplateRoute extends GetRoute
A GET route that renders a Jinjava HTML template.
See Also:
  • Jinjava
  • Field Details

    • notificationDefinitions

      private final Map<String,String> notificationDefinitions
      A map of notification definitions to be used in the Jinjava HTML template. The keys are the URL names of the notifications, and the values are the notification messages.
  • Constructor Details

    • HTMLTemplateRoute

      protected HTMLTemplateRoute(App app, String path)
      Creates a new HTMLTemplateRoute.
      Parameters:
      app - app instance, passed to the super contructor
      path - the path of the route, passed to the super contructor
  • Method Details

    • handleGet

      public Object handleGet(spark.Request request, spark.Response response) throws SQLException
      Renders a Jinjava HTML template. It populates the context with the request session attributes and the result of the populateContext(Request, Response) method. It also adds a notification and its type to the context if the request contains an "error" or "success" query parameter.
      Specified by:
      handleGet in class GetRoute
      Parameters:
      request - the request
      response - the response
      Returns:
      the rendered HTML template as a string
      Throws:
      SQLException - if a database access error occurs in any subclass implementation
    • getHTMLTemplatePath

      public abstract String getHTMLTemplatePath(spark.Request request)
      Returns the path to the Jinjava HTML template.
    • getNotificationDefinitions

      public Map<String,String> getNotificationDefinitions()
      Returns a map of notification definitions to be used in the Jinjava HTML template. Intended to be overridden by subclasses, providing their own definitions based on all redirects which point the user to the route with any error or success tags.
      Returns:
      the definitions as an URL name-notification message map.
    • populateContext

      public Map<String,Object> populateContext(spark.Request request, spark.Response response) throws SQLException
      Returns additional context to populate the Jinjava HTML template with. By default, it returns an empty map. Intended to be overriden by subclasses.
      Parameters:
      request - the request
      response - the response
      Returns:
      the context as a variable-value map
      Throws:
      SQLException - if a database access error occurs in any subclass implementation