@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;
 }
 @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;
 }
Beispiel #3
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 />";
    }
  }