예제 #1
0
 @Bean
 public TemplateResolver templateResolver() {
   TemplateResolver templateResolver = new ServletContextTemplateResolver();
   templateResolver.setPrefix("/WEB-INF/views/");
   templateResolver.setSuffix(".html");
   templateResolver.setTemplateMode("HTML5");
   return templateResolver;
 }
예제 #2
0
 @Bean
 public TemplateResolver templateResolver() {
   TemplateResolver templateResolver = new ClassLoaderTemplateResolver();
   templateResolver.setPrefix("views/");
   templateResolver.setSuffix(".html");
   templateResolver.setTemplateMode("HTML5");
   return templateResolver;
 }
 @Bean
 public TemplateResolver templateResolver() {
   TemplateResolver templateResolver = new ServletContextTemplateResolver();
   templateResolver.setPrefix(VIEWS);
   templateResolver.setSuffix(".html");
   templateResolver.setTemplateMode("HTML5");
   templateResolver.setCacheable(false);
   return templateResolver;
 }
예제 #4
0
 /*
  * Configure Template Resolver - Thymeleaf
  */
 @Bean
 public TemplateResolver webTemplateResolver() {
   TemplateResolver templateResolver = new ServletContextTemplateResolver();
   templateResolver.setPrefix(TEMPLATE_RESOLVER_PREFIX);
   templateResolver.setSuffix(TEMPLATE_RESOLVER_SUFFIX);
   templateResolver.setTemplateMode(TEMPLATE_RESOLVER_TEMPLATE_MODE);
   templateResolver.setCharacterEncoding(TEMPLATE_RESOLVER_CHAR_ENCODING);
   templateResolver.setCacheable(false);
   return templateResolver;
 }
 @Bean
 public TemplateResolver taskTemplateResolver() {
   final TemplateResolver resolver = new TemplateResolver();
   resolver.setPrefix(this.storageService.getStoragePath());
   resolver.setSuffix(".html");
   resolver.setTemplateMode("HTML5");
   resolver.setOrder(3);
   resolver.setCacheable(false);
   resolver.setCharacterEncoding("UTF-8");
   resolver.setResourceResolver(new OlympusCustomThymeleafResourceResolver());
   return resolver;
 }
 @Override
 public String generatePageHtml(ITestPage test) {
   TemplateResolver templateResolver = new ClassLoaderTemplateResolver();
   templateResolver.setTemplateMode("HTML5");
   templateResolver.setCharacterEncoding("UTF-8");
   TemplateEngine templateEngine = new TemplateEngine();
   templateEngine.setTemplateResolver(templateResolver);
   Locale locale = LocaleUtils.toLocale("fr");
   final Context ctx = new Context(locale);
   ctx.setVariable("test", test);
   String htmlOutput = templateEngine.process("new_test_report_template.html", ctx);
   return htmlOutput;
 }
 @Bean
 public TemplateResolver customTemplateResolver() {
   if (StringUtils.isEmpty(this.customPagesPath)) {
     return null;
   }
   final TemplateResolver resolver = new TemplateResolver();
   resolver.setPrefix(this.customPagesPath);
   resolver.setSuffix(".html");
   resolver.setTemplateMode("HTML5");
   resolver.setOrder(4);
   resolver.setCacheable(false);
   resolver.setCharacterEncoding("UTF-8");
   resolver.setResourceResolver(new FileResourceResolver());
   return resolver;
 }
예제 #8
0
  public void setResponse(Pair<ABSString, ABS.StdLib.List<ABSValue>> pair) throws Exception {
    TemplateResolver templateResolver = new TemplateResolver();
    templateResolver.setTemplateMode("HTML5");
    templateResolver.setSuffix(".html");
    templateResolver.setResourceResolver(new ResourceResolver());

    TemplateEngine templateEngine = new TemplateEngine();
    templateEngine.setTemplateResolver(templateResolver);

    List_Cons<ABSValue> data;

    if (pair != null) {
      String view = DataTransformer.convertABSStringToJavaString((ABSString) pair.getArg(0));
      Context ctx = new Context();
      if (!(pair.getArg(1) instanceof List_Nil)) {
        data = (List_Cons<ABSValue>) pair.getArg(1);
        ArrayList<Object> dataModels = DataTransformer.convertABSListToJavaList(data);

        if (dataModels.size() > 1) {
          ctx.setVariable("dataList", dataModels);
        } else {
          ctx.setVariable("data", dataModels.get(0));
        }
      }
      ctx.setVariable("requestMethod", this.request.getMethod());
      ctx.setVariable("requestURI", this.request.getRequestURI());
      ctx.setVariable("requestContextPath", this.request.getContextPath());
      ctx.setVariable(
          "requestRoute", this.getRoute(request.getRequestURI(), request.getContextPath()));

      this.response = templateEngine.process(view, ctx);
    } else {
      this.response = "<h3>ERROR 404: PAGE NOT FOUND</h3>";
      this.response += "<span style='font-size:0.8em;'>ABS Server: " + new Date() + "</span><br />";
    }
  }