Class FreeMarkerConsoleWeblet

java.lang.Object
org.jgrapes.core.internal.ComponentVertex
org.jgrapes.core.Component
org.jgrapes.webconsole.base.ConsoleWeblet
org.jgrapes.webconsole.base.freemarker.FreeMarkerConsoleWeblet
All Implemented Interfaces:
Iterable<org.jgrapes.core.ComponentType>, org.jgrapes.core.Channel, org.jgrapes.core.ComponentType, org.jgrapes.core.Eligible, org.jgrapes.core.Manager
Direct Known Subclasses:
AlpineJsConsoleWeblet, Bootstrap4Weblet, JQueryUiWeblet, VueJsConsoleWeblet

public abstract class FreeMarkerConsoleWeblet extends ConsoleWeblet
A console weblet that uses a freemarker template to generate the HTML source for the console page.
  • Field Details

  • Constructor Details

    • FreeMarkerConsoleWeblet

      public FreeMarkerConsoleWeblet(org.jgrapes.core.Channel webletChannel, org.jgrapes.core.Channel consoleChannel, URI consolePrefix)
      Instantiates a new free marker console weblet.
      Parameters:
      webletChannel - the weblet channel
      consoleChannel - the console channel
      consolePrefix - the console prefix
  • Method Details

    • prependClassTemplateLoader

      Prepend a class template loader to the list of loaders derived from the class hierarchy.
      Parameters:
      classloader - the class loader
      path - the path
      Returns:
      the free marker console weblet
    • prependClassTemplateLoader

      Convenience version of prependClassTemplateLoader(ClassLoader, String) that derives the path from the class’s package name.
      Parameters:
      clazz - the clazz
      Returns:
      the free marker console weblet
    • createConsoleBaseModel

      Creates the console base model.
      Returns:
      the base model
    • expandConsoleModel

      protected Map<String,Object> expandConsoleModel(Map<String,Object> model, org.jgrapes.http.events.Request.In.Get event, UUID consoleConnectionId)
      Invoked by renderConsole to expand the base model with information from the current event.
      Parameters:
      model - the model
      event - the event
      consoleConnectionId - the console connection id
      Returns:
      the map
    • renderConsole

      protected void renderConsole(org.jgrapes.http.events.Request.In.Get event, org.jgrapes.io.IOSubchannel channel, UUID consoleConnectionId) throws IOException, InterruptedException
      Render the console page using the freemarker template “console.ftl.html”.

      The template for the console page (and all included templates) are loaded using the a list of template class loaders created as follows:

      1. Start with the actual type of the console conlet.

      2. Using the current type, add a freemarker class template loader ClassTemplateLoader(ClassLoader, String) that uses the package name as path (all dots replaced with slashes).

      3. Repeat step 2 with the super class of the current type until type FreeMarkerConsoleWeblet is reached.

      This approach allows a (base) console weblet to provide a console page template that includes another template e.g. “footer.ftl.html” to provide a specific part of the console page. A derived console weblet can then provide its own “footer.ftl.html” and thus override the version from the base class(es).

      Specified by:
      renderConsole in class ConsoleWeblet
      Parameters:
      event - the event
      channel - the channel
      Throws:
      IOException - Signals that an I/O exception has occurred.
      InterruptedException - the interrupted exception