Package freemarker.template

Examples of freemarker.template.Template.process()


        }

        // Create the content from the template.
        StringWriter writer = new StringWriter();
        try {
            template.process(model, writer);
        }
        catch (Exception e) {
            // Couldn't process the template?
            throw new ShouldNeverHappenException(e);
        }
View Full Code Here


    }

    private void process(String resource, Map<String, Object> dataModel, Writer writer) throws TemplateException,
            IOException {
        Template template = configuration.getTemplate(resource);
        template.process(dataModel, writer);
    }

    private String templateResource(String format) {
        return viewProperties.getProperty(format);
    }
View Full Code Here

      BufferedWriter bw = new BufferedWriter(out);
     
      /*
       * 合并处理数据与模型
       */
      template.process(root, bw);
      bw.flush();
      bw.close();
     
      return codeFile.getAbsolutePath();
    } catch (Exception e) {
View Full Code Here

        Map<String, Object> ctx = FastMap.newInstance();
        ctx.put("doc", nodeModel);
        ctx.put("entityName", entityName);
        StringWriter outWriter = new StringWriter();
        Template template = getDocTemplate(templatePath);
        template.process(ctx, outWriter);
        outWriter.close();
        result = outWriter.toString();
        return result;
    }
View Full Code Here

                    BeansWrapper wrapper = BeansWrapper.getDefaultInstance();
                    TemplateHashModel staticModels = wrapper.getStaticModels();
                    context.put("Static", staticModels);

                    context.put("doc", nodeModel);
                    template.process(context, outWriter);
                    String s = outWriter.toString();
                    if (Debug.verboseOn()) Debug.logVerbose("transformed xml: " + s, module);

                    EntitySaxReader reader = new EntitySaxReader(delegator);
                    reader.setUseTryInsertMethod(this.useTryInsertMethod);
View Full Code Here

                fmcontext.put("doc", nodeModel);
                BeansWrapper wrapper = BeansWrapper.getDefaultInstance();
                TemplateHashModel staticModels = wrapper.getStaticModels();
                fmcontext.put("Static", staticModels);

                template.process(fmcontext, outWriter);
                fulltext = outWriter.toString();
            } catch (Exception ex) {
                return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsErrrorProcessingTemplateFile", UtilMisc.toMap("filename", fmfilename, "errorString", ex.getMessage()), locale));
            }
        }
View Full Code Here

 
      try {
        Reader r = new StringReader(template);
      Template t = new Template("unknown", r, freeMarkerEngine);
       
      t.process(getContext(), output);          
      }
      catch (IOException e) {
          throw new ExporterException("Error while processing template string", e);
      }
      catch (TemplateException te) {
View Full Code Here

        rootContext = "Unknown context";
      }
     
      try {
        Template template = freeMarkerEngine.getTemplate(templateName);
        template.process(getContext(), output);           
        }
        catch (IOException e) {
            throw new ExporterException("Error while processing " + rootContext + " with template " + templateName, e);
        }
        catch (TemplateException te) {         
View Full Code Here

            if (null == currentUser) {
                topBarModel.put(Common.LOGIN_URL, userService.createLoginURL(Common.ADMIN_INDEX_URI));
                topBarModel.put("loginLabel", langPropsService.get("loginLabel"));
                topBarModel.put("registerLabel", langPropsService.get("registerLabel"));

                topBarTemplate.process(topBarModel, stringWriter);

                return stringWriter.toString();
            }

            topBarModel.put(Common.IS_LOGGED_IN, true);
View Full Code Here

            final String userName = currentUser.getString(User.USER_NAME);

            topBarModel.put(User.USER_NAME, userName);

            topBarTemplate.process(topBarModel, stringWriter);

            return stringWriter.toString();
        } catch (final JSONException e) {
            LOGGER.log(Level.ERROR, "Gens top bar HTML failed", e);
            throw new ServiceException(e);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.