/** * This method is called from {@link #doExecute(String, ActionInvocation)} * to obtain the FreeMarker configuration object that this result will use * for template loading. This is a hook that allows you to custom-configure * the configuration object in a subclass, or to fetch it from an IoC * container. <p/><b>The default implementation obtains the configuration * from the ConfigurationManager instance. </b> */ protected Configuration getConfiguration() throws TemplateException { return FreemarkerManager.getInstance().getConfiguration( ServletActionContext.getServletContext()); }
/** * Method Hook: <p/> * Returns a Freemarker's Template bsaed on the <code>templatePath</code> * supplied. * * @param templatePath * @return * @throws IOException * @throws TemplateException */ protected Template getFreemarkerTemplate(String templatePath) throws IOException, TemplateException { FreemarkerManager freemarkerManager = FreemarkerManager.getInstance(); Configuration configuration = freemarkerManager.getConfiguration(JspSupportServlet.jspSupportServlet.getServletContext()); return configuration.getTemplate(templatePath); }
/** * This method is called from {@link #doExecute(String, ActionInvocation)} to obtain the * FreeMarker configuration object that this result will use for template loading. This is a * hook that allows you to custom-configure the configuration object in a subclass, or to fetch * it from an IoC container. * <p/> * <b> * The default implementation obtains the configuration from the ConfigurationManager instance. * </b> */ protected Configuration getConfiguration() throws TemplateException { return FreemarkerManager.getInstance().getConfiguration(ServletActionContext.getServletContext()); }
protected Configuration createConfiguration() throws TemplateException { return FreemarkerManager.getInstance().getConfiguration(getServletContext()); }
freemarker.template.Configuration config = FreemarkerManager.getInstance().getConfiguration(ctx); Template template = config.getTemplate("/com/opensymphony/webwork/dispatcher/error.ftl");
FreemarkerManager freemarkerManager = FreemarkerManager.getInstance(); Configuration config = freemarkerManager.getConfiguration(servletContext);
throws ServletException, IOException { try { FreemarkerManager fmm = FreemarkerManager.getInstance();
protected TemplateModel createModel(ObjectWrapper wrapper, ServletContext servletContext, HttpServletRequest request, HttpServletResponse response) throws TemplateModelException { OgnlValueStack stack = ServletActionContext.getContext().getValueStack(); Object action = null; if (ServletActionContext.getContext().getActionInvocation() != null) { action = ServletActionContext.getContext().getActionInvocation().getAction(); } TemplateModel model = FreemarkerManager.getInstance().buildTemplateModel(stack, action, servletContext, request, response, wrapper); return model; }
/** * Build the instance of the ScopesHashModel, including JspTagLib support * <p/>Objects added to the model are <p/> * <ul> * <li>Application - servlet context attributes hash model * <li>JspTaglibs - jsp tag lib factory model * <li>Request - request attributes hash model * <li>Session - session attributes hash model * <li>req - the HttpServletRequst object for direct access * <li>res - the HttpServletResponse object for direct access * <li>stack - the OgnLValueStack instance for direct access * <li>ognl - the instance of the OgnlTool * <li>action - the action itself * <li>exception - optional : the JSP or Servlet exception as per the * servlet spec (for JSP Exception pages) * <li>webwork - instance of the WebWorkUtil class * </ul> */ protected TemplateModel createModel() throws TemplateModelException { ServletContext servletContext = ServletActionContext .getServletContext(); HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); OgnlValueStack stack = ServletActionContext.getContext() .getValueStack(); return FreemarkerManager.getInstance().buildTemplateModel(stack, invocation.getAction(), servletContext, request, response, wrapper); }
/** * Build the instance of the ScopesHashModel, including JspTagLib support * <p/> * Objects added to the model are * <p/> * <ul> * <li>Application - servlet context attributes hash model * <li>JspTaglibs - jsp tag lib factory model * <li>Request - request attributes hash model * <li>Session - session attributes hash model * <li>req - the HttpServletRequst object for direct access * <li>res - the HttpServletResponse object for direct access * <li>stack - the OgnLValueStack instance for direct access * <li>ognl - the instance of the OgnlTool * <li>action - the action itself * <li>exception - optional : the JSP or Servlet exception as per the servlet spec (for JSP Exception pages) * <li>webwork - instance of the WebWorkUtil class * </ul> */ protected TemplateModel createModel() throws TemplateModelException { ServletContext servletContext = ServletActionContext.getServletContext(); HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); OgnlValueStack stack = ServletActionContext.getContext().getValueStack(); Object action = null; if(invocation!= null ) action = invocation.getAction(); //Added for NullPointException return FreemarkerManager.getInstance().buildTemplateModel(stack, action, servletContext, request, response, wrapper); }
/** * Create a Freemarker's Model through {@link FreemarkerManager#buildTemplateModel(OgnlValueStack, Object, ServletContext, HttpServletRequest, HttpServletResponse, ObjectWrapper)}. * * @return * @throws TemplateException */ protected SimpleHash createModel() throws TemplateException { FreemarkerManager freemarkerManager = FreemarkerManager.getInstance(); ActionInvocation invocation = ActionContext.getContext().getActionInvocation(); ServletContext servletContext = JspSupportServlet.jspSupportServlet.getServletContext(); OgnlValueStack stack = ActionContext.getContext().getValueStack(); ObjectWrapper wrapper = freemarkerManager.getConfiguration(servletContext).getObjectWrapper(); Object action = null; if(invocation!= null ) action = invocation.getAction(); //Added for NullPointException return freemarkerManager.buildTemplateModel(stack, action, servletContext, request, response, wrapper); } }