Package freemarker.template

Examples of freemarker.template.Template.process()


           Writer out = new BufferedWriter(new FileWriter(new File(directory, fileName)));
           try {
               Map<String, Props> root = new HashMap<String, Props>();
               root.put("props", props);
               templ.process(root, out);
           } finally {
               out.close();
           }
       } catch (IOException ioe) {
           ioe.printStackTrace();
View Full Code Here


            dataModel.put("statefulSessionBeanCount", statefulSessionBeanCount);
            dataModel.put("messageDrivenBeanCount", messageDrivenBeanCount);

            byteArrayOutputStream = new ByteArrayOutputStream();
            Writer out = new OutputStreamWriter(byteArrayOutputStream);
            template.process(dataModel, out);
        } catch (Exception e) {
            throw new RuntimeException("Failed to add ejb-jar.xml to EJB-JAR.", e);
        }

        Asset ejbJarXml = new ByteArrayAsset(byteArrayOutputStream.toByteArray());               
View Full Code Here

            template = templateConfig.getTemplate("wfsvGetDiff.ftl");
        }

        try {
            template.setOutputEncoding("UTF-8");
            template.process(diffReaders, new OutputStreamWriter(output, Charset.forName("UTF-8")));
        } catch (TemplateException e) {
            String msg = "Error occured processing template.";
            throw (IOException) new IOException(msg).initCause(e);
        } finally {
          for (int i = 0; i < diffReaders.length; i++) {
View Full Code Here

            template = templateConfig.getTemplate("wfsvGetLog.ftl");
        }

        try {
            template.setOutputEncoding("UTF-8");
            template.process(fc, new OutputStreamWriter(output, Charset.forName("UTF-8")));
        } catch (TemplateException e) {
            String msg = "Error occured processing template.";
            throw (IOException) new IOException(msg).initCause(e);
        }
    }
View Full Code Here

        Template t = null;
       
        t = lookupTemplate(featureType, template,lookup);

        try {
            t.process(feature, writer);
        } catch (TemplateException e) {
            String msg = "Error occured processing template.";
            throw (IOException) new IOException(msg).initCause(e);
        }
    }
View Full Code Here

        public InputStream getInputStream()
                throws ResourceStreamNotFoundException {
            ByteArrayOutputStream output = new ByteArrayOutputStream();
            try {
                Template t = cfg.getTemplate(templateName);
                t.process(model, new OutputStreamWriter(output));

                return new ByteArrayInputStream(output.toByteArray());
            } catch (IOException e) {
                throw (ResourceStreamNotFoundException) new ResourceStreamNotFoundException(
                        "Could not find template for: " + clazz).initCause(e);
View Full Code Here

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

                template.process(fmcontext, outWriter);
                s = outWriter.toString();
            } catch (Exception ex) {
                return ServiceUtil.returnError("ERROR processing template file (" + fmfilename + "): " + ex.getMessage());
            }
        }
View Full Code Here

    }
 
    private void processTemplateForGeneratorControl(Map templateModel,String templateFile) throws IOException, TemplateException {
      templateModel.put("gg", gg);
      Template template = getFreeMarkerTemplate(templateFile);
      template.process(templateModel, IOHelper.NULL_WRITER);
    }
   
    /** 处理文件路径的变量变成输出路径 */
    private String proceeForOutputFilepath(Map filePathModel,String templateFile) throws IOException {
      String outputFilePath = templateFile;
View Full Code Here

  }

  protected void serialize(Serializable obj, HttpServletResponse response, String page) throws IOException {
    Template template = configuration.getTemplate(page, getLocale());
    try {
      template.process(new ModelMap(obj), response.getWriter());
    } catch (TemplateException e) {
      throw new RuntimeException(e.getMessage(), e);
    }
  }
View Full Code Here

        Configuration cfg = new Configuration();
        cfg.setObjectWrapper(new DefaultObjectWrapper());
        cfg.setLocalizedLookup(false);
        Template template = new Template("test", new StringReader(ftlText), cfg, PluginConstants.UTF_ENCODING);
        StringWriter out = new StringWriter();
        template.process(new EditorHashModel(variableNames), out);
        out.flush();
        return out.toString();
    }

    @SuppressWarnings("serial")
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.