Examples of TemplateException


Examples of com.alibaba.citrus.service.template.TemplateException

            // ������jsp���޸�content type��locale��charset����Ӧ����ģ���ⲿ������
            HttpServletResponse responseWrapper = new JspResponse(response);

            dispatcher.include(requestWrapper, responseWrapper);
        } catch (ServletException e) {
            throw new TemplateException(e);
        }

        return "";
    }
View Full Code Here

Examples of com.alibaba.citrus.service.template.TemplateException

            error(templateName, e);
        }
    }

    private void error(String templateName, Throwable e) {
        throw new TemplateException("Error rendering FreeMarker template: " + templateName, e);
    }
View Full Code Here

Examples of com.alibaba.citrus.service.template.TemplateException

            if (value != null) {
                try {
                    configuration.setSetting(key, value);
                } catch (freemarker.template.TemplateException e) {
                    throw new TemplateException("invalid key and value: " + key + " = " + value, e);
                }
            }
        }
    }
View Full Code Here

Examples of com.elibom.jogger.template.TemplateException

    try {
      templateEngine.render(templateName, attributes, response.getWriter());
      this.written = true;
    } catch (IOException e) {
      throw new TemplateException(e);
    }
    return this;
  }
View Full Code Here

Examples of com.xfltr.hapax.TemplateException

        }
      }
    }

    if (end_node == -1) {
      throw new TemplateException("Unable to find matching [end] node.");
    }

    if (behavior.trueBranch(dict)) {
      if (else_node == -1) {
        // no [else]
View Full Code Here

Examples of com.xfltr.hapax.TemplateException

        }
      }
    }

    if (end_node == -1) {
      throw new TemplateException("Unable to find matching [end] node.");
    }

    return new Range(define_node_idx + 1, end_node, end_node);
  }
View Full Code Here

Examples of freemarker.template.TemplateException

    throws TemplateException, IOException
    {
        // Determine the path
        final TemplateModel path = (TemplateModel)params.get("path");
        if(path == null) {
            throw new TemplateException("Missing required parameter 'path'", env);
        }
        if(!(path instanceof TemplateScalarModel)) {
            throw new TemplateException("Expected a scalar model. 'path' is instead " +
                    path.getClass().getName(), env);
        }
        final String strPath = ((TemplateScalarModel)path).getAsString();
        if(strPath == null) {
            throw new TemplateException("String value of 'path' parameter is null", env);
        }
       
        // See whether we need to use a custom response (if we're inside a TTM
        // or TDM or macro nested body, we'll need to as then the current
        // FM environment writer is not identical to HTTP servlet response
        // writer.
        final Writer envOut = env.getOut();
        final HttpServletResponse wrappedResponse;
        if(envOut == response.getWriter()) {
            // Don't bother wrapping if environment's writer is same as
            // response writer
            wrappedResponse = response;
        }
        else {
            final PrintWriter printWriter = (envOut instanceof PrintWriter) ?
                (PrintWriter)envOut :
                new PrintWriter(envOut);
            // Otherwise, create a response wrapper that will pass the
            // env writer, potentially first wrapping it in a print
            // writer when it ain't one already.
            wrappedResponse = new HttpServletResponseWrapper(response) {
                public PrintWriter getWriter() {
                    return printWriter;
                }
            };
        }

        // Determine inherit_params value
        final boolean inheritParams;
        final TemplateModel inheritParamsModel = (TemplateModel)params.get("inherit_params");
        if(inheritParamsModel == null) {
            // defaults to true when not specified
            inheritParams = true;
        }
        else {
            if(!(inheritParamsModel instanceof TemplateBooleanModel)) {
                throw new TemplateException("'inherit_params' should be a boolean but it is " +
                        inheritParamsModel.getClass().getName() + " instead", env);
            }
            inheritParams = ((TemplateBooleanModel)inheritParamsModel).getAsBoolean();
        }
       
        // Get explicit params, if any
        final TemplateModel paramsModel = (TemplateModel)params.get("params");
       
        // Determine whether we need to wrap the request
        final HttpServletRequest wrappedRequest;
        if(paramsModel == null && inheritParams) {
            // Inherit original request params & no params explicitly
            // specified, so use the original request
            wrappedRequest = request;
        }
        else {
            // In any other case, use a custom request wrapper
            final Map paramsMap;
            if(paramsModel != null) {
                // Convert params to a Map
                final Object unwrapped = DeepUnwrap.unwrap(paramsModel);
                if(!(unwrapped instanceof Map)) {
                    throw new TemplateException("Expected 'params' to unwrap " +
                            "into a java.util.Map. It unwrapped into " +
                            unwrapped.getClass().getName() + " instead.", env);
                }
                paramsMap = (Map)unwrapped;
            }
            else {
                paramsMap = Collections12.EMPTY_MAP;
            }
            wrappedRequest = new CustomParamsRequest(request, paramsMap,
                    inheritParams);
        }
       
        // Finally, do the include
        try {
            request.getRequestDispatcher(strPath).include(wrappedRequest,
                    wrappedResponse);
        }
        catch (ServletException e) {
            throw new TemplateException(e, 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

                && (trustedTemplateNames.contains(templateName)
                        || hasMatchingPrefix(templateName))) {
            return TemplateClassResolver.SAFER_RESOLVER.resolve(className, env, template);
        } else {
            if (!allowedClasses.contains(className)) {
                throw new TemplateException(
                        "Instantiating " + className + " is not allowed in the " +
                        "template for security reasons. (If you meet this problem " +
                        "when using ?new in a template, you may want to look " +
                        "at the \"" + Configurable.NEW_BUILTIN_CLASS_RESOLVER_KEY +
                        "\" setting in the FreeMarker configuration.)",
                        env);
            } else {
                try {
                    return ClassUtil.forName(className);
                } catch (ClassNotFoundException e) {
                    throw new TemplateException(e, env);
                }
            }
        }
    }
View Full Code Here

Examples of freemarker.template.TemplateException

        }
       
        protected void checkDateTypeNotUnknown(int dateType, Environment env)
        throws TemplateException {
            if (dateType == TemplateDateModel.UNKNOWN) {
                throw new TemplateException(
                        "Unknown date type: ?" + biName + " needs a date value "
                        + "where it's known if it's a date-only, time-only, or "
                        + "date+time value. Use ?time, ?date or ?datetime "
                        + "before ? " + biName + " to estabilish that.",
                        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.