Java Code Examples for org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver

The following examples show how to use org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: onetwo   Source File: WebFtlsContextConfig.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
	@ConditionalOnMissingBean({FreeMarkerConfig.class, FreeMarkerViewResolver.class})
	public FreeMarkerConfigurer freeMarkerConfigurer() {
		PluginFreeMarkerConfigurer configurer = new PluginFreeMarkerConfigurer();
		applyProperties(configurer);
		String[] paths = this.properties.getTemplateLoaderPath();
//		paths = ArrayUtils.add(paths, WEBFTLS_PATH);
		configurer.setTemplateLoaderPaths(paths);
		
		List<WithAnnotationBeanData<FreeMarkerViewTools>> tools = SpringUtils.getBeansWithAnnotation(applicationContext, FreeMarkerViewTools.class);
		tools.forEach(t->{
			String name = t.getAnnotation().value();
			if(StringUtils.isBlank(name)){
				name = t.getBean().getClass().getSimpleName();
			}
			configurer.setFreemarkerVariable(name, t.getBean());
			logger.info("registered FreeMarkerViewTools : {}", name);
		});
		return configurer;
	}
 
Example 2
@BeforeEach
void beforeMethod() {
  MockitoAnnotations.initMocks(this);
  FreeMarkerViewResolver freeMarkerViewResolver = new FreeMarkerViewResolver();
  freeMarkerViewResolver.setSuffix(".ftl");

  when(menuReaderService.findMenuItemPath(MetadataManagerController.METADATA_MANAGER))
      .thenReturn("/test/path");

  when(appSettings.getLanguageCode()).thenReturn("nl");
  User user = mock(User.class);
  when(userAccountService.getCurrentUser()).thenReturn(user);

  MetadataManagerController metadataEditorController =
      new MetadataManagerController(menuReaderService, metadataManagerService);

  mockMvc =
      MockMvcBuilders.standaloneSetup(metadataEditorController)
          .setLocaleResolver(localeResolver)
          .setMessageConverters(new FormHttpMessageConverter(), gsonHttpMessageConverter)
          .build();
}
 
Example 3
@BeforeEach
void setUp() {
  FreeMarkerViewResolver freeMarkerViewResolver = new FreeMarkerViewResolver();
  freeMarkerViewResolver.setSuffix(".ftl");
  mockMvc =
      MockMvcBuilders.standaloneSetup(authenticationController)
          .setMessageConverters(
              new FormHttpMessageConverter(), new GsonHttpMessageConverter(new Gson()))
          .build();

  reset(authenticationSettings);
  reset(reCaptchaService);
  reset(appSettings);
  when(reCaptchaService.validate("validCaptcha")).thenReturn(true);
  reset(accountService); // mocks in the config class are not resetted after each test
}
 
Example 4
@Bean
public FreeMarkerViewResolver freemarkerViewResolver() {
    FreeMarkerViewResolver resolver = new FreeMarkerViewResolver();
    resolver.setCache(true);
    resolver.setPrefix("");
    resolver.setSuffix(".ftl");
    return resolver;
}
 
Example 5
Source Project: pacbot   Source File: GlobalConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public ViewResolver viewResolver() {
    FreeMarkerViewResolver resolver = new FreeMarkerViewResolver();
    resolver.setCache(true);
    resolver.setPrefix("");
    resolver.setSuffix(".html");
    resolver.setContentType("text/html; charset=UTF-8");
    return resolver;
}
 
Example 6
Source Project: halo   Source File: WebMvcAutoConfiguration.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Configuring view resolver
 *
 * @param registry registry
 */
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
    FreeMarkerViewResolver resolver = new FreeMarkerViewResolver();
    resolver.setAllowRequestOverride(false);
    resolver.setCache(false);
    resolver.setExposeRequestAttributes(false);
    resolver.setExposeSessionAttributes(false);
    resolver.setExposeSpringMacroHelpers(true);
    resolver.setSuffix(HaloConst.SUFFIX_FTL);
    resolver.setContentType("text/html; charset=UTF-8");
    registry.viewResolver(resolver);
}
 
Example 7
Source Project: Spring-5.0-Cookbook   Source File: SpringContextConfig.java    License: MIT License 5 votes vote down vote up
@Bean(name = "viewResolverFTL")
public FreeMarkerViewResolver getViewResolverFtl() {
    FreeMarkerViewResolver viewResolver = new FreeMarkerViewResolver();
    viewResolver.setPrefix("");
    viewResolver.setSuffix(".ftl");
    viewResolver.setOrder(1);
    return viewResolver;
}
 
Example 8
Source Project: Spring-5.0-Cookbook   Source File: SpringWebReactiveConfig.java    License: MIT License 5 votes vote down vote up
@Bean(name = "viewResolverFTL")
public FreeMarkerViewResolver getViewResolverFtl() {
    FreeMarkerViewResolver viewResolver = new FreeMarkerViewResolver();
    viewResolver.setPrefix("");
    viewResolver.setSuffix(".ftl");
    viewResolver.setOrder(1);
    return viewResolver;
}
 
Example 9
Source Project: Spring-5.0-Cookbook   Source File: SpringContextConfig.java    License: MIT License 5 votes vote down vote up
@Bean(name = "viewResolverFTL")
public FreeMarkerViewResolver getViewResolverFtl() {
    FreeMarkerViewResolver viewResolver = new FreeMarkerViewResolver();
    viewResolver.setPrefix("");
    viewResolver.setSuffix(".ftl");
    viewResolver.setOrder(1);
    return viewResolver;
}
 
Example 10
Source Project: cms   Source File: FreeMarkerAutoconfigure.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
    public ViewResolver viewResolver(FreeMarkerViewResolver resolver) {
//        resolver.setCache(true);
//        resolver.setPrefix("");
//        resolver.setSuffix(".ftl");
//        resolver.setContentType("text/html; charset=UTF-8");
        resolver.setViewClass(DefaultFreemarkerView.class);
        return resolver;
    }
 
Example 11
/** Enable spring freemarker viewresolver. All freemarker template names should end with '.ftl' */
@Bean
public ViewResolver viewResolver() {
  FreeMarkerViewResolver resolver = new FreeMarkerViewResolver();
  resolver.setCache(true);
  resolver.setSuffix(".ftl");
  resolver.setContentType("text/html;charset=UTF-8");
  return resolver;
}
 
Example 12
Source Project: tutorials   Source File: EmailConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean 
public FreeMarkerViewResolver freemarkerViewResolver() { 
    FreeMarkerViewResolver resolver = new FreeMarkerViewResolver(); 
    resolver.setCache(true); 
    resolver.setPrefix(""); 
    resolver.setSuffix(".ftl"); 
    return resolver; 
}
 
Example 13
Source Project: tutorials   Source File: FreemarkerConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean 
public FreeMarkerViewResolver freemarkerViewResolver() { 
    FreeMarkerViewResolver resolver = new FreeMarkerViewResolver(); 
    resolver.setCache(true); 
    resolver.setPrefix(""); 
    resolver.setSuffix(".ftl"); 
    return resolver; 
}
 
Example 14
Source Project: tutorials   Source File: SpringWebConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public FreeMarkerViewResolver freemarkerViewResolver() {
    FreeMarkerViewResolver resolver = new FreeMarkerViewResolver();
    resolver.setCache(true);
    resolver.setPrefix("");
    resolver.setSuffix(".ftl");
    return resolver;
}
 
Example 15
Source Project: spring-analysis-note   Source File: ViewResolverRegistry.java    License: MIT License 4 votes vote down vote up
public FreeMarkerRegistration() {
	super(new FreeMarkerViewResolver());
	getViewResolver().setSuffix(".ftl");
}
 
Example 16
@Bean
public FreeMarkerViewResolver freeMarkerViewResolver() {
	return new FreeMarkerViewResolver("", ".ftl");
}
 
Example 17
Source Project: spring-analysis-note   Source File: ViewResolverRegistryTests.java    License: MIT License 4 votes vote down vote up
@Test
public void freeMarker() {
	this.registry.freeMarker().prefix("/").suffix(".fmt").cache(false);
	FreeMarkerViewResolver resolver = checkAndGetResolver(FreeMarkerViewResolver.class);
	checkPropertyValues(resolver, "prefix", "/", "suffix", ".fmt", "cacheLimit", 0);
}
 
Example 18
Source Project: spring-analysis-note   Source File: ViewResolverRegistryTests.java    License: MIT License 4 votes vote down vote up
@Test
public void freeMarkerDefaultValues() {
	this.registry.freeMarker();
	FreeMarkerViewResolver resolver = checkAndGetResolver(FreeMarkerViewResolver.class);
	checkPropertyValues(resolver, "prefix", "", "suffix", ".ftl");
}
 
Example 19
Source Project: java-technology-stack   Source File: ViewResolverRegistry.java    License: MIT License 4 votes vote down vote up
public FreeMarkerRegistration() {
	super(new FreeMarkerViewResolver());
	getViewResolver().setSuffix(".ftl");
}
 
Example 20
@Bean
public FreeMarkerViewResolver freeMarkerViewResolver() {
	return new FreeMarkerViewResolver("", ".ftl");
}
 
Example 21
Source Project: java-technology-stack   Source File: ViewResolverRegistryTests.java    License: MIT License 4 votes vote down vote up
@Test
public void freeMarker() {
	this.registry.freeMarker().prefix("/").suffix(".fmt").cache(false);
	FreeMarkerViewResolver resolver = checkAndGetResolver(FreeMarkerViewResolver.class);
	checkPropertyValues(resolver, "prefix", "/", "suffix", ".fmt", "cacheLimit", 0);
}
 
Example 22
Source Project: java-technology-stack   Source File: ViewResolverRegistryTests.java    License: MIT License 4 votes vote down vote up
@Test
public void freeMarkerDefaultValues() {
	this.registry.freeMarker();
	FreeMarkerViewResolver resolver = checkAndGetResolver(FreeMarkerViewResolver.class);
	checkPropertyValues(resolver, "prefix", "", "suffix", ".ftl");
}
 
Example 23
Source Project: lams   Source File: ViewResolverRegistry.java    License: GNU General Public License v2.0 4 votes vote down vote up
public FreeMarkerRegistration() {
	super(new FreeMarkerViewResolver());
	getViewResolver().setSuffix(".ftl");
}
 
Example 24
private FreeMarkerRegistration() {
	super(new FreeMarkerViewResolver());
	getViewResolver().setSuffix(".ftl");
}
 
Example 25
@Bean
public FreeMarkerViewResolver freeMarkerViewResolver() {
	FreeMarkerViewResolver viewResolver = new FreeMarkerViewResolver();
	viewResolver.setSuffix(".ftl");
	return viewResolver;
}
 
Example 26
@Test
public void freeMarker() {
	this.registry.freeMarker().prefix("/").suffix(".fmt").cache(false);
	FreeMarkerViewResolver resolver = checkAndGetResolver(FreeMarkerViewResolver.class);
	checkPropertyValues(resolver, "prefix", "/", "suffix", ".fmt", "cacheLimit", 0);
}
 
Example 27
@Test
public void freeMarkerDefaultValues() {
	this.registry.freeMarker();
	FreeMarkerViewResolver resolver = checkAndGetResolver(FreeMarkerViewResolver.class);
	checkPropertyValues(resolver, "prefix", "", "suffix", ".ftl");
}