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

  A `RequestProcessor` using Thymeleaf as a rendering engine.
  Processing uses an `IWebContext`, with some additional context variables:
  - `SESSION`
    Provides a `Map<String,Object>` containing the current appNG session.
    Example:

         <div th:text="${#ctx.SESSION['subject'].name}"></div>

  - `APP`
    Provides the `Application`s properties as `Properties`
    Example:

         <div th:text="${#ctx.APP.getString('myProp')"></div>

  - `SITE`
    Provides the `Site`s properties as `Properties`. See `SiteProperties` for a list of available properties.
    Example:

         <div th:text="${#ctx.SITE.getString('timeZone')"></div>

  - `PLATFORM`
    Provides the platform properties as `Properties`. See `Platform.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 and Description
    --- | ---
    `static class` | `ThymeleafProcessor.AppNG` This is a helper class to make it easier for the thymeleaf template to interact with appNG's `Platform` 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 and Description
    `ThymeleafProcessor(DocumentBuilderFactory dbf)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and 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, Properties platformProperties, Site site, ApplicationProvider applicationProvider, Charset charset)`
    `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`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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 that `RequestProcessor.init(HttpServletRequest, HttpServletResponse, PathInfo, String)` must have been called before.
      Parameters:
        `applicationSite` - the `Site` for which the process the request
        `debugRootFolder` - the folder to write debug files to
      Returns:
        the result of calling the `Application` and applying the `Template`. This should then be written to the `HttpServletResponse`
      Throws:
        `InvalidConfigurationException` - if something goes wrong while processing the request
      See Also:
        `RequestProcessor.processPlatform(Site)`

    - #### writeStackTrace

          protected void writeStackTrace(File outfolder,
                                         Exception e)

    - #### 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,
                                                          Properties platformProperties,
                                                          Site site,
                                                          ApplicationProvider applicationProvider,
                                                          Charset charset)

    - #### getGlobalTemplateResolver

          protected org.thymeleaf.templateresolver.ITemplateResolver getGlobalTemplateResolver(Charset charset,
                                                                                               Boolean devMode)

    - #### addTemplates

          protected void addTemplates(List<Template> templates)

      Specified by:
        `addTemplates` in class `AbstractRequestProcessor`

Copyright © 2011–2023 aiticon GmbH. All rights reserved.