Examples of TemplateException


Examples of freemarker.template.TemplateException

            importedTemplate = env.getTemplateForImporting(templateNameString);
        }
        catch (ParseException pe) {
            String msg = "Error parsing imported template "
                        + templateNameString;
            throw new TemplateException(msg, pe, env);
        }
        catch (IOException ioe) {
            String msg = "Error reading imported file "
                        + templateNameString;
            throw new TemplateException(msg, ioe, env);
        }
        env.importLib(importedTemplate, namespace);
    }
View Full Code Here

Examples of freemarker.template.TemplateException

            this.env = env;
            TemplateModel nsModel = null;
            if(namespaceExp != null) {
                nsModel = namespaceExp.getAsTemplateModel(env);
                if (!(nsModel instanceof Environment.Namespace)) {
                    throw new TemplateException(
                        "namespace parameter does not specify "
                        + "a namespace. It is a "
                        + nsModel.getClass().getName(), env);
                }
            }
View Full Code Here

Examples of freemarker.template.TemplateException

       
        public ConstructorFunction(String classname, Environment env, Template template) throws TemplateException {
            this.env = env;
            cl = env.getNewBuiltinClassResolver().resolve(classname, env, template);
            if (!TM_CLASS.isAssignableFrom(cl)) {
                throw new TemplateException("Class " + cl.getName() + " does not implement freemarker.template.TemplateModel", env);
            }
            if (BEAN_MODEL_CLASS.isAssignableFrom(cl)) {
                throw new TemplateException("Bean Models cannot be instantiated using the ?new built-in", env);
            }
            if (JYTHON_MODEL_CLASS != null && JYTHON_MODEL_CLASS.isAssignableFrom(cl)) {
                throw new TemplateException("Jython Models cannot be instantiated using the ?new built-in", env);
            }
        }
View Full Code Here

Examples of freemarker.template.TemplateException

            System.out.println(resp.toString());
            TemplateTestCase.compare(reference,output);
        }
        catch(Exception e) {
            e.printStackTrace();
            throw new TemplateException(e, null);
        }
    }
View Full Code Here

Examples of freemarker.template.TemplateException

        public ConstructorFunction(String classname, Environment env) throws TemplateException {
            this.env = env;
            try {
                cl = ClassUtil.forName(classname);
                if (!TM_CLASS.isAssignableFrom(cl)) {
                    throw new TemplateException("Class " + cl.getName() + " does not implement freemarker.template.TemplateModel", env);
                }
                if (BEAN_MODEL_CLASS.isAssignableFrom(cl)) {
                    throw new TemplateException("Bean Models cannot be instantiated using the ?new built-in", env);
                }
                if (JYTHON_MODEL_CLASS != null && JYTHON_MODEL_CLASS.isAssignableFrom(cl)) {
                    throw new TemplateException("Jython Models cannot be instantiated using the ?new built-in", env);
                }
            }
            catch (ClassNotFoundException cnfe) {
                throw new TemplateException(cnfe, env);
            }
        }
View Full Code Here

Examples of freemarker.template.TemplateException

    public void testEvaluateWriterException() throws TemplateException, IOException {
        TemplateDirectiveBody body = createMock(TemplateDirectiveBody.class);
        Writer writer = createMock(Writer.class);

        body.render(writer);
        expectLastCall().andThrow(new TemplateException(null));

        replay(body, writer);
        try {
            FreemarkerModelBody modelBody = new FreemarkerModelBody(null, body);
            modelBody.evaluate(writer);
View Full Code Here

Examples of freemarker.template.TemplateException

    public void testEvaluateWriterException() throws TemplateException, IOException {
        TemplateDirectiveBody body = createMock(TemplateDirectiveBody.class);
        Writer writer = createMock(Writer.class);

        body.render(writer);
        expectLastCall().andThrow(new TemplateException(null));

        replay(body, writer);
        try {
            FreemarkerModelBody modelBody = new FreemarkerModelBody(null, body);
            modelBody.evaluate(writer);
View Full Code Here

Examples of freemarker.template.TemplateException

    if (result != null) {
      try {
        env.getOut().write(result);
      } catch (IOException ex) {
        throw new TemplateException("Error writing [" + result + "] to Freemarker.", ex, env);
      }
    } else {
      renderBody(env, body);
    }
  }
View Full Code Here

Examples of freemarker.template.TemplateException

    if (result != null) {
      try {
        env.getOut().write(result);
      } catch (IOException ex) {
        throw new TemplateException("Error writing [" + result + "] to Freemarker.", ex, env);
      }
    } else {
      renderBody(env, body);
    }
  }
View Full Code Here

Examples of freemarker.template.TemplateException

    // Print out the principal value if not null
    if (result != null) {
      try {
        env.getOut().write(result);
      } catch (IOException ex) {
        throw new TemplateException("Error writing [" + result + "] to Freemarker.", ex, env);
      }
    }
  }
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.