Example usage for org.springframework.ui.freemarker FreeMarkerConfigurationFactory setTemplateLoaderPath

List of usage examples for org.springframework.ui.freemarker FreeMarkerConfigurationFactory setTemplateLoaderPath

Introduction

In this page you can find the example usage for org.springframework.ui.freemarker FreeMarkerConfigurationFactory setTemplateLoaderPath.

Prototype

public void setTemplateLoaderPath(String templateLoaderPath) 

Source Link

Document

Set the Freemarker template loader path via a Spring resource location.

Usage

From source file:com.gnizr.web.action.user.TestRequestPasswordReset.java

protected void setUp() throws Exception {
    super.setUp();

    gnizrConfiguration = new GnizrConfiguration();
    gnizrConfiguration.setSiteContactEmail("admin@mysite.com");
    gnizrConfiguration.setWebApplicationUrl("http://foo.com/gnizr");

    FreeMarkerConfigurationFactory factory = new FreeMarkerConfigurationFactory();
    factory.setTemplateLoaderPath("/templates");
    freemarkerEngine = factory.createConfiguration();

    userManager = new UserManager(getGnizrDao());
    tokenManager = new TokenManager();
    tokenManager.setUserManager(userManager);
    tokenManager.init();//from  ww  w  . java 2 s .  com

    templateMessage = new SimpleMailMessage();
    templateMessage.setSubject("Reset Password");

    mailSender = new JavaMailSenderImpl();
    mailSender.setHost("localhost");

    action = new RequestPasswordReset();
    action.setUserManager(userManager);
    action.setTokenManager(tokenManager);
    action.setVerifyResetTemplate(templateMessage);
    action.setMailSender(mailSender);
    action.setFreemarkerEngine(freemarkerEngine);
    action.setGnizrConfiguration(gnizrConfiguration);
}

From source file:com.gnizr.web.action.user.TestApproveUserAccount.java

protected void setUp() throws Exception {
    super.setUp();

    mailSender = new JavaMailSenderImpl();
    mailSender.setHost("localhost");

    gnizrConfiguration = new GnizrConfiguration();
    gnizrConfiguration.setSiteContactEmail("admin@mysite.com");
    gnizrConfiguration.setWebApplicationUrl("http://foo.com/gnizr");

    FreeMarkerConfigurationFactory factory = new FreeMarkerConfigurationFactory();
    factory.setTemplateLoaderPath("/templates");
    freemarkerEngine = factory.createConfiguration();

    welcomeMessage = new SimpleMailMessage();
    welcomeMessage.setSubject("Welcome");

    userManager = new UserManager(getGnizrDao());
    tokenManager = new TokenManager();
    tokenManager.setUserManager(userManager);
    tokenManager.init();//from   www  .j  a  va 2s .c o m

    action = new ApproveUserAccount();
    action.setUserManager(userManager);
    action.setTokenManager(tokenManager);
    action.setGnizrConfiguration(gnizrConfiguration);
    action.setWelcomeEmailTemplate(welcomeMessage);
    action.setFreemarkerEngine(freemarkerEngine);
    action.setMailSender(mailSender);

    username = "hchen1";
    token = tokenManager.createResetToken(new User(username));
}

From source file:com.gnizr.web.action.user.TestRegisterUser.java

protected void setUp() throws Exception {
    super.setUp();

    gnizrConfiguration = new GnizrConfiguration();
    gnizrConfiguration.setSiteContactEmail("admin@mysite.com");
    gnizrConfiguration.setWebApplicationUrl("http://foo.com/gnizr");

    FreeMarkerConfigurationFactory factory = new FreeMarkerConfigurationFactory();
    factory.setTemplateLoaderPath("/templates");
    freemarkerEngine = factory.createConfiguration();

    userManager = new UserManager(getGnizrDao());
    tokenManager = new TokenManager();
    tokenManager.setUserManager(userManager);
    tokenManager.init();//  w w  w . ja v a 2  s.c o  m

    templateMessage = new SimpleMailMessage();
    templateMessage.setSubject("Email Verification");

    notifyMessage = new SimpleMailMessage();
    notifyMessage.setSubject("Account Registration Pending");

    approvalMessage = new SimpleMailMessage();
    approvalMessage.setSubject("Account Registration Approval");

    mailSender = new JavaMailSenderImpl();
    mailSender.setHost("localhost");

    action = new RegisterUser();
    action.setUserManager(userManager);
    action.setTokenManager(tokenManager);
    action.setVerifyEmailTemplate(templateMessage);
    action.setApprovalEmailTemplate(approvalMessage);
    action.setNotifyEmailTemplate(notifyMessage);
    action.setMailSender(mailSender);
    action.setFreemarkerEngine(freemarkerEngine);
    action.setGnizrConfiguration(gnizrConfiguration);
}

From source file:org.craftercms.commons.mail.impl.EmailFactoryImplTest.java

private Configuration createFreeMarkerConfig() throws Exception {
    FreeMarkerConfigurationFactory factory = new FreeMarkerConfigurationFactory();
    factory.setDefaultEncoding(ENCODING);
    factory.setTemplateLoaderPath("classpath:mail/templates");

    return factory.createConfiguration();
}