Package freemarker.template

Examples of freemarker.template.Template.process()


        cfg.setLocalizedLookup(false);
        cfg.setTemplateExceptionHandler(new MyTemplateExceptionHandler())
        Template template = new Template("test", new StringReader(new String(formBytes, "UTF-8")), cfg, "UTF-8");
        StringWriter out = new StringWriter();
        VariablesCollector validationHashModel = new VariablesCollector(formNode.getProcessDefinition().getVariableNames(true));
        template.process(validationHashModel, out);
        return validationHashModel.getUsedVariables();
    }

    public static class MyTemplateExceptionHandler implements TemplateExceptionHandler {
        public void handleTemplateException(TemplateException te, Environment env, Writer out) throws TemplateException {
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

                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

        model.getData().put(annotation.responseName(), o);

        try {
            OutputStreamWriter writer = new OutputStreamWriter(os);
            template.process(new ModelWrapper(model.getData(), manager), writer);
            writer.flush();
        } catch (TemplateException e) {
            throw new RuntimeException("Unable to write FreeMarker response.", e);
        }
    }
View Full Code Here

        // Get the template object
        Template template = configuration.getTemplate(templatePath);

        // Merge the data-model and the template
        try {
            template.process(model, writer);

        } catch (freemarker.template.TemplateException fmte) {
            throw new TemplateException(fmte);
        }
    }
View Full Code Here

        // Get the template object
        Template template = configuration.getTemplate(templatePath);

        // Merge the data-model and the template
        try {
            template.process(model, writer);

        } catch (freemarker.template.TemplateException fmte) {
            throw new TemplateException(fmte);
        }
    }
View Full Code Here

            model.put("title",page.getTitle());
            model.put("body",page.getBody());
            model.put("page.properties", new SimpleHash(page.getProperties()));

            // finally, render it
            template.process(model, res.getWriter());
        } catch (Exception e) {
            String msg = "Error applying decorator: " + e.getMessage();
            LOG.error(msg, e);
            throw new ServletException(msg, e);
        }
View Full Code Here

                HashMap<String,Object> data = new HashMap<String,Object>();
                data.put("exception", e);
                data.put("unknown", Location.UNKNOWN);
                data.put("chain", chain);
                data.put("locator", new Locator());
                template.process(data, response.getWriter());
                response.getWriter().close();
            } catch (Exception exp) {
                try {
                    response.sendError(code, "Unable to show problem report: " + exp);
                } catch (IOException ex) {
View Full Code Here

        // Give subclasses a chance to hook into preprocessing
        if (preTemplateProcess(template, model)) {
            try {
                // Process the template
                template.process(model, getWriter());
            } finally {
                // Give subclasses a chance to hook into postprocessing
                postTemplateProcess(template, model);
            }
        }
View Full Code Here

        // Give subclasses a chance to hook into preprocessing
        if (preTemplateProcess(template, model)) {
            try {
                // Process the template
                PortletActionContext.getRenderResponse().setContentType(pContentType);
                template.process(model, getWriter());
            } finally {
                // Give subclasses a chance to hook into postprocessing
                postTemplateProcess(template, model);
            }
        }
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.