Package org.appng.core.model
Class ThymeleafProcessor
- java.lang.Object
-
- org.appng.core.model.AbstractRequestProcessor
-
- org.appng.core.model.ThymeleafProcessor
-
- All Implemented Interfaces:
RequestProcessor
public class ThymeleafProcessor extends AbstractRequestProcessor
ARequestProcessor
using Thymeleaf as a rendering engine.
Processing uses anIWebContext
, with some additional context variables:SESSION
Provides aMap<String,Object>
containing the current appNG session.
Example:<div th:text="${#ctx.SESSION['subject'].name}"></div>
APP
Provides theApplication
s properties asProperties
Example:<div th:text="${#ctx.APP.getString('myProp')"></div>
SITE
Provides theSite
s properties asProperties
. SeeSiteProperties
for a list of available properties.
Example:<div th:text="${#ctx.SITE.getString('timeZone')"></div>
PLATFORM
Provides the platform properties asProperties
. SeePlatform.Property
for a list of available properties.
Example:<div th:text="${#ctx.PLATFORM.getBoolean('debugMode')"></div>
- Author:
- Matthias Müller
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ThymeleafProcessor.AppNG
This is a helper class to make it easier for the thymeleaf template to interact with appNG'sPlatform
object.
-
Field Summary
-
Fields inherited from class org.appng.core.model.AbstractRequestProcessor
contentLength, contentType, env, INDEX_HTML, marshallService, navigationBuilder, outputFormat, outputType, pathInfo, PLATFORM_XML, redirect, servletRequest, servletResponse, STACKTRACE_TXT, templatePath
-
-
Constructor Summary
Constructors Constructor Description ThymeleafProcessor(DocumentBuilderFactory dbf)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addTemplates(List<Template> templates)
protected org.thymeleaf.templateresolver.ITemplateResolver
getApplicationTemplateResolver(String application, Charset charset, Boolean devMode, File tplFolder, Set<String> patterns)
protected org.thymeleaf.context.IWebContext
getContext(Platform platform, ApplicationProvider applicationProvider)
protected org.thymeleaf.linkbuilder.ILinkBuilder
getGlobalLinkBuilder(String templatePrefix)
protected org.thymeleaf.templateresolver.ITemplateResolver
getGlobalTemplateResolver(Charset charset, Boolean devMode)
protected org.thymeleaf.linkbuilder.ILinkBuilder
getLinkBuilder(ApplicationProvider applicationProvider, String templatePrefix, File tplFolder)
protected ThymeleafTemplateEngine
prepareEngine(org.springframework.context.ConfigurableApplicationContext context)
String
processWithTemplate(Site applicationSite, File debugRootFolder)
Processes the request, including the processing of the template.protected void
writeStackTrace(File outfolder, Exception e)
protected void
writeTemplateFiles(File outfolder, ThymeleafTemplateEngine templateEngine)
-
Methods inherited from class org.appng.core.model.AbstractRequestProcessor
determineActiveAuthentication, determineFormatAndType, getApplicationProvider, getContentLength, getContentType, getDebugFilePrefix, getMarshallService, getOutputFormat, getOutputType, getPlatform, getTemplatePath, init, initPlatform, isRedirect, processPlatform, setMarshallService, setRedirect, setTemplatePath, writeDebugFile, writeErrorPage
-
-
-
-
Constructor Detail
-
ThymeleafProcessor
public ThymeleafProcessor(@Autowired DocumentBuilderFactory dbf)
-
-
Method Detail
-
processWithTemplate
public String processWithTemplate(Site applicationSite, File debugRootFolder) throws InvalidConfigurationException
Description copied from interface:RequestProcessor
Processes the request, including the processing of the template. Note thatRequestProcessor.init(HttpServletRequest, HttpServletResponse, PathInfo, String)
must have been called before.- Parameters:
applicationSite
- theSite
for which the process the requestdebugRootFolder
- the folder to write debug files to- Returns:
- the result of calling the
Application
and applying theTemplate
. This should then be written to theHttpServletResponse
- Throws:
InvalidConfigurationException
- if something goes wrong while processing the request- See Also:
RequestProcessor.processPlatform(Site)
-
writeTemplateFiles
protected void writeTemplateFiles(File outfolder, ThymeleafTemplateEngine templateEngine) throws IOException
- Throws:
IOException
-
getApplicationTemplateResolver
protected org.thymeleaf.templateresolver.ITemplateResolver getApplicationTemplateResolver(String application, Charset charset, Boolean devMode, File tplFolder, Set<String> patterns)
-
getContext
protected org.thymeleaf.context.IWebContext getContext(Platform platform, ApplicationProvider applicationProvider) throws InvalidConfigurationException
- Throws:
InvalidConfigurationException
-
getGlobalLinkBuilder
protected org.thymeleaf.linkbuilder.ILinkBuilder getGlobalLinkBuilder(String templatePrefix)
-
getLinkBuilder
protected org.thymeleaf.linkbuilder.ILinkBuilder getLinkBuilder(ApplicationProvider applicationProvider, String templatePrefix, File tplFolder)
-
prepareEngine
protected ThymeleafTemplateEngine prepareEngine(org.springframework.context.ConfigurableApplicationContext context)
-
getGlobalTemplateResolver
protected org.thymeleaf.templateresolver.ITemplateResolver getGlobalTemplateResolver(Charset charset, Boolean devMode)
-
addTemplates
protected void addTemplates(List<Template> templates)
- Specified by:
addTemplates
in classAbstractRequestProcessor
-
-