Example #1
0
 private void setTimeZoneForDateTimeFilter() {
   JodaTimeContext jodaTimeContext = getJodaTimeContext();
   // check JodaTimeContext first and use it if set
   if (jodaTimeContext != null)
     engine.getConfiguration().setTimezone(jodaTimeContext.getTimeZone().toTimeZone());
   else { // try attrib param next
     String timeZone = (String) getAttributesMap().get(PARAM_TIMEZONE);
     if (timeZone != null) {
       engine.getConfiguration().setTimezone(TimeZone.getTimeZone(timeZone));
       JodaTimeContext context = JodaTimeContextHolder.getJodaTimeContext();
       if (context == null) context = new JodaTimeContext();
       context.setTimeZone(DateTimeZone.forID(timeZone));
       JodaTimeContextHolder.setJodaTimeContext(context);
     }
   }
 }
Example #2
0
  @Override
  protected void renderMergedOutputModel(
      Map<String, Object> model, HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    setTimeZoneForDateTimeFilter();

    String templateFile = getServletContext().getRealPath(getUrl());
    {
      // ThemeResolver themeResolver = RequestContextUtils
      // .getThemeResolver(request);
      // String theme = themeResolver.resolveThemeName(request);
      // if (logger.isDebugEnabled()) {
      // logger.debug("Current theme is " + theme);
      // }
      // templateFile = theme + File.separator + getUrl();
      // templateFile = getServletContext().getRealPath(templateFile);
    }
    Locale locale = RequestContextUtils.getLocale(request);
    response.setContentType(getContentType());
    engine.process(templateFile, model, response.getWriter(), locale);
  }
 public static String render(String templateFile, Map<String, Object> data) throws IOException {
   return engine.process(templateFile, data);
 }
 static {
   engine = new TemplateEngine();
   engine.getConfiguration().setWorkspace("/Users/pc/Code/balanced-java/src/scenarios");
 }