Search in sources :

Example 1 with PostProcessor

use of org.thymeleaf.postprocessor.PostProcessor in project cas by apereo.

the class CasThemesConfiguration method registeredServiceViewResolver.

@Bean
public ViewResolver registeredServiceViewResolver() {
    final RegisteredServiceThemeBasedViewResolver r = new RegisteredServiceThemeBasedViewResolver(servicesManager, argumentExtractors, thymeleafProperties.getPrefix(), thymeleafProperties.getSuffix());
    r.setApplicationContext(this.thymeleafViewResolver.getApplicationContext());
    r.setCache(this.thymeleafProperties.isCache());
    if (!r.isCache()) {
        r.setCacheLimit(0);
    }
    r.setCacheUnresolved(this.thymeleafViewResolver.isCacheUnresolved());
    r.setCharacterEncoding(this.thymeleafViewResolver.getCharacterEncoding());
    r.setContentType(this.thymeleafViewResolver.getContentType());
    r.setExcludedViewNames(this.thymeleafViewResolver.getExcludedViewNames());
    r.setOrder(this.thymeleafViewResolver.getOrder());
    r.setRedirectContextRelative(this.thymeleafViewResolver.isRedirectContextRelative());
    r.setRedirectHttp10Compatible(this.thymeleafViewResolver.isRedirectHttp10Compatible());
    r.setStaticVariables(this.thymeleafViewResolver.getStaticVariables());
    final SpringTemplateEngine engine = SpringTemplateEngine.class.cast(this.thymeleafViewResolver.getTemplateEngine());
    engine.addDialect(new IPostProcessorDialect() {

        @Override
        public int getDialectPostProcessorPrecedence() {
            return Integer.MAX_VALUE;
        }

        @Override
        public Set<IPostProcessor> getPostProcessors() {
            return Collections.singleton(new PostProcessor(TemplateMode.parse(thymeleafProperties.getMode()), CasThymeleafOutputTemplateHandler.class, Integer.MAX_VALUE));
        }

        @Override
        public String getName() {
            return CasThymeleafOutputTemplateHandler.class.getSimpleName();
        }
    });
    r.setTemplateEngine(engine);
    r.setViewNames(this.thymeleafViewResolver.getViewNames());
    return r;
}
Also used : SpringTemplateEngine(org.thymeleaf.spring4.SpringTemplateEngine) Set(java.util.Set) RegisteredServiceThemeBasedViewResolver(org.apereo.cas.services.web.RegisteredServiceThemeBasedViewResolver) IPostProcessorDialect(org.thymeleaf.dialect.IPostProcessorDialect) PostProcessor(org.thymeleaf.postprocessor.PostProcessor) IPostProcessor(org.thymeleaf.postprocessor.IPostProcessor) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

Set (java.util.Set)1 RegisteredServiceThemeBasedViewResolver (org.apereo.cas.services.web.RegisteredServiceThemeBasedViewResolver)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1 IPostProcessorDialect (org.thymeleaf.dialect.IPostProcessorDialect)1 IPostProcessor (org.thymeleaf.postprocessor.IPostProcessor)1 PostProcessor (org.thymeleaf.postprocessor.PostProcessor)1 SpringTemplateEngine (org.thymeleaf.spring4.SpringTemplateEngine)1