Package freemarker.template

Examples of freemarker.template.Configuration


            StringWriter outWriter = new StringWriter();

            Template template = null;
            try {
                Configuration conf = org.ofbiz.base.util.template.FreeMarkerWorker.getDefaultOfbizConfig();
                template = new Template("FMImportFilter", templateReader, conf);
                Map<String, Object> fmcontext = FastMap.newInstance();

                NodeModel nodeModel = NodeModel.parse(ins);
                fmcontext.put("doc", nodeModel);
View Full Code Here


            } else {
                try {
                    Reader templateReader = new InputStreamReader(templateUrl.openStream());

                    StringWriter outWriter = new StringWriter();
                    Configuration config = new Configuration();
                    config.setObjectWrapper(BeansWrapper.getDefaultInstance());
                    config.setSetting("datetime_format", "yyyy-MM-dd HH:mm:ss.SSS");

                    Template template = new Template("FMImportFilter", templateReader, config);
                    NodeModel nodeModel = NodeModel.wrap(this.rootNodeForTemplate);

                    Map<String, Object> context = FastMap.newInstance();
View Full Code Here

        URL screenFileUrl = FlexibleLocation.resolveLocation(fileUrl, null);
        String urlStr = screenFileUrl.toString();
        URI uri = new URI(urlStr);
        File f = new File(uri);
        FileReader templateReader = new FileReader(f);
        Configuration conf = makeDefaultOfbizConfig();
        template = new Template("FMImportFilter", templateReader, conf);
        return template;
    }
View Full Code Here

        template = new Template("FMImportFilter", templateReader, conf);
        return template;
    }

    public static Configuration makeDefaultOfbizConfig() throws TemplateException, IOException {
        Configuration config = new Configuration();
        config.setObjectWrapper(BeansWrapper.getDefaultInstance());
        config.setSetting("datetime_format", "yyyy-MM-dd HH:mm:ss.SSS");
        Configuration defaultOfbizConfig = config;
        return defaultOfbizConfig;
    }
View Full Code Here

     * @param c a Class object to use for retrieving the template resource
     * @param type the MediaType of the result
     */
    public FreemarkerFormat(String templateName, Class c, MediaType type){
        myTemplateFileName = templateName;
        myConfig = new Configuration();
        myConfig.setClassForTemplateLoading(c, "");
        myType = type;
    }
View Full Code Here

import freemarker.template.Template;


public class FeatureDescriptionTemplateTest extends TestCase {
    public void testTemplate() throws Exception {
        Configuration cfg = new Configuration();
        cfg.setObjectWrapper(new FeatureWrapper());
        cfg.setClassForTemplateLoading(FeatureTemplate.class, "");

        Template template = cfg.getTemplate("description.ftl");
        assertNotNull(template);

        //create some data
        GeometryFactory gf = new GeometryFactory();
        SimpleFeatureType featureType = DataUtilities.createType("testType",
View Full Code Here

    public static Test suite() {
        return new OneTimeTestSetup(new OpenLayersMapTemplateTest());
    }
   
    public void test() throws Exception {
        Configuration cfg = new Configuration();
        cfg.setClassForTemplateLoading(OpenLayersMapProducer.class, "");
        cfg.setObjectWrapper(new BeansWrapper());

        Template template = cfg.getTemplate("OpenLayersMapTemplate.ftl");
        assertNotNull(template);

        GetMapRequest request = createGetMapRequest(MockData.BASIC_POLYGONS);
        WMSMapContext mapContext = new WMSMapContext();
        mapContext.addLayer(createMapLayer(MockData.BASIC_POLYGONS));
View Full Code Here

            resp.setContentType("text/xml");
           
            if ( search ) {
                //send back the opensearch template
                //write out the opensearch template
                Configuration cfg = new Configuration();
                cfg.setClassForTemplateLoading(getClass(), "");
               
                Map ctx = new HashMap();
                ctx.put("CONTACT_ADDRESS", myGeoserver.getContactEmail());
                ctx.put( "LAYER", layer );
                ctx.put( "BASE_URL", baseUrl );
               
                Template t = cfg.getTemplate("opensearchdescription.ftl");
                PrintWriter writer = resp.getWriter();
                t.process(ctx, writer);
                writer.flush();
            }
            else {
View Full Code Here

    public FilterFunction_freemarker() {
        super("freemarker");
        // initialize the template engine, this is static to maintain a cache
        // over instantiations of kml writer
        templateConfig = new Configuration();
        templateConfig.setObjectWrapper(new FeatureWrapper());
        templateLoader = new StringTemplateLoader();
        templateConfig.setTemplateLoader(templateLoader);
    }
View Full Code Here

    }
   
    @Override
    protected Configuration createConfiguration(Object data, Class clazz) {
       
        Configuration cfg = super.createConfiguration(data, clazz);
        cfg.setClassForTemplateLoading( getClass(), "templates");
        return cfg;
    }
View Full Code Here

TOP

Related Classes of freemarker.template.Configuration

Copyright © 2018 www.massapicom. 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.