Class FreeMarkerConsoleWeblet
- All Implemented Interfaces:
Iterable<ComponentType>
,Channel
,ComponentType
,Eligible
,Manager
- Direct Known Subclasses:
Bootstrap4Weblet
,JQueryUiWeblet
,VueJsConsoleWeblet
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jgrapes.webconsole.base.ConsoleWeblet
ConsoleWeblet.ConsoleChannel, ConsoleWeblet.ConsoleResourceChannel
Nested classes/interfaces inherited from interface org.jgrapes.core.Channel
Channel.Default
-
Field Summary
Modifier and TypeFieldDescriptionprotected Configuration
Initialized with a base FreeMarker configuration.static final String
-
Constructor Summary
ConstructorDescriptionFreeMarkerConsoleWeblet
(Channel webletChannel, Channel consoleChannel, URI consolePrefix) Instantiates a new free marker console weblet. -
Method Summary
Modifier and TypeMethodDescriptionCreates the console base model.expandConsoleModel
(Map<String, Object> model, Request.In.Get event, UUID consoleConnectionId) Invoked byrenderConsole
to expand thebase model
with information from the current event.prependClassTemplateLoader
(Class<?> clazz) Convenience version ofprependClassTemplateLoader(ClassLoader, String)
that derives the path from the class’s package name.prependClassTemplateLoader
(ClassLoader classloader, String path) Prepend a class template loader to the list of loaders derived from the class hierarchy.protected void
renderConsole
(Request.In.Get event, IOSubchannel channel, UUID consoleConnectionId) Render the console page using the freemarker template “console.ftl.html”.Methods inherited from class org.jgrapes.webconsole.base.ConsoleWeblet
connectionInactivityTimeout, connectionNetworkTimeout, connectionRefreshInterval, console, consoleHierarchy, consoleResourceBundle, onClosed, onConsoleCommand, onDiscardSession, onGet, onGetRedirect, onInput, onResourceRequestCompleted, onSetLocale, onSetLocaleCompleted, onUpgraded, prefix, prependConsoleResourceProvider, prependResourceBundleProvider, provideConsoleResource, renderSupport, setConnectionInactivityTimeout, setConnectionNetworkTimeout, setConnectionRefreshInterval, setUseMinifiedResources, styling, supportedLocales, updateSupportedLocales, useMinifiedResources
Methods inherited from class org.jgrapes.core.Component
channel, component, defaultCriterion, isEligibleFor, setName
Methods inherited from class org.jgrapes.core.internal.ComponentVertex
activeEventPipeline, addHandler, attach, channelReplacements, children, componentPath, componentVertex, detach, fire, initComponentsHandlers, iterator, name, newEventPipeline, newEventPipeline, parent, registerAsGenerator, root, toString, unregisterAsGenerator
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
UTF_8
- See Also:
-
freeMarkerConfig
Initialized with a base FreeMarker configuration.
-
-
Constructor Details
-
FreeMarkerConsoleWeblet
Instantiates a new free marker console weblet.- Parameters:
webletChannel
- the weblet channelconsoleChannel
- the console channelconsolePrefix
- 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 loaderpath
- the path- Returns:
- the free marker console weblet
-
prependClassTemplateLoader
Convenience version ofprependClassTemplateLoader(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, Request.In.Get event, UUID consoleConnectionId) Invoked byrenderConsole
to expand thebase model
with information from the current event.- Parameters:
model
- the modelevent
- the eventconsoleConnectionId
- the console connection id- Returns:
- the map
-
renderConsole
protected void renderConsole(Request.In.Get event, 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:
-
Start with the actual type of the console conlet.
-
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). -
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 classConsoleWeblet
- Parameters:
event
- the eventchannel
- the channel- Throws:
IOException
- Signals that an I/O exception has occurred.InterruptedException
- the interrupted exception
-
-