freemarker.ext.servlet.ServletContextHashModel Java Examples
The following examples show how to use
freemarker.ext.servlet.ServletContextHashModel.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FreeMarkerView.java From spring-analysis-note with MIT License | 6 votes |
/** * Invoked on startup. Looks for a single FreeMarkerConfig bean to * find the relevant Configuration for this factory. * <p>Checks that the template for the default Locale can be found: * FreeMarker will check non-Locale-specific templates if a * locale-specific one is not found. * @see freemarker.cache.TemplateCache#getTemplate */ @Override protected void initServletContext(ServletContext servletContext) throws BeansException { if (getConfiguration() != null) { this.taglibFactory = new TaglibFactory(servletContext); } else { FreeMarkerConfig config = autodetectConfiguration(); setConfiguration(config.getConfiguration()); this.taglibFactory = config.getTaglibFactory(); } GenericServlet servlet = new GenericServletAdapter(); try { servlet.init(new DelegatingServletConfig()); } catch (ServletException ex) { throw new BeanInitializationException("Initialization of GenericServlet adapter failed", ex); } this.servletContextHashModel = new ServletContextHashModel(servlet, getObjectWrapper()); }
Example #2
Source File: FreeMarkerView.java From java-technology-stack with MIT License | 6 votes |
/** * Invoked on startup. Looks for a single FreeMarkerConfig bean to * find the relevant Configuration for this factory. * <p>Checks that the template for the default Locale can be found: * FreeMarker will check non-Locale-specific templates if a * locale-specific one is not found. * @see freemarker.cache.TemplateCache#getTemplate */ @Override protected void initServletContext(ServletContext servletContext) throws BeansException { if (getConfiguration() != null) { this.taglibFactory = new TaglibFactory(servletContext); } else { FreeMarkerConfig config = autodetectConfiguration(); setConfiguration(config.getConfiguration()); this.taglibFactory = config.getTaglibFactory(); } GenericServlet servlet = new GenericServletAdapter(); try { servlet.init(new DelegatingServletConfig()); } catch (ServletException ex) { throw new BeanInitializationException("Initialization of GenericServlet adapter failed", ex); } this.servletContextHashModel = new ServletContextHashModel(servlet, getObjectWrapper()); }
Example #3
Source File: FreeMarkerView.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Invoked on startup. Looks for a single FreeMarkerConfig bean to * find the relevant Configuration for this factory. * <p>Checks that the template for the default Locale can be found: * FreeMarker will check non-Locale-specific templates if a * locale-specific one is not found. * @see freemarker.cache.TemplateCache#getTemplate */ @Override protected void initServletContext(ServletContext servletContext) throws BeansException { if (getConfiguration() != null) { this.taglibFactory = new TaglibFactory(servletContext); } else { FreeMarkerConfig config = autodetectConfiguration(); setConfiguration(config.getConfiguration()); this.taglibFactory = config.getTaglibFactory(); } GenericServlet servlet = new GenericServletAdapter(); try { servlet.init(new DelegatingServletConfig()); } catch (ServletException ex) { throw new BeanInitializationException("Initialization of GenericServlet adapter failed", ex); } this.servletContextHashModel = new ServletContextHashModel(servlet, getObjectWrapper()); }
Example #4
Source File: FreeMarkerView.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Invoked on startup. Looks for a single FreeMarkerConfig bean to * find the relevant Configuration for this factory. * <p>Checks that the template for the default Locale can be found: * FreeMarker will check non-Locale-specific templates if a * locale-specific one is not found. * @see freemarker.cache.TemplateCache#getTemplate */ @Override protected void initServletContext(ServletContext servletContext) throws BeansException { if (getConfiguration() != null) { this.taglibFactory = new TaglibFactory(servletContext); } else { FreeMarkerConfig config = autodetectConfiguration(); setConfiguration(config.getConfiguration()); this.taglibFactory = config.getTaglibFactory(); } GenericServlet servlet = new GenericServletAdapter(); try { servlet.init(new DelegatingServletConfig()); } catch (ServletException ex) { throw new BeanInitializationException("Initialization of GenericServlet adapter failed", ex); } this.servletContextHashModel = new ServletContextHashModel(servlet, getObjectWrapper()); }
Example #5
Source File: AbstractTestExecutorService.java From entando-core with GNU Lesser General Public License v3.0 | 6 votes |
protected TemplateModel createModel(ObjectWrapper wrapper) throws Throwable { HttpServletRequest request = super.getRequestContext().getRequest(); HttpServletResponse response = super.getRequestContext().getResponse(); ServletContext servletContext = request.getSession().getServletContext(); AllHttpScopesHashModel hashModel = new AllHttpScopesHashModel(wrapper, servletContext, request); //super.createModel(wrapper, servletContext, request, response); ControllerServlet servlet = new ControllerServlet(); MockServletConfig config = new MockServletConfig(servletContext); servlet.init(config); ServletContextHashModel newServletContextModel = new ServletContextHashModel(servlet, wrapper); ServletContextHashModel servletContextModel = new ServletContextHashModel(servlet, wrapper); servletContext.setAttribute(ATTR_APPLICATION_MODEL, servletContextModel); TaglibFactory taglibs = new TaglibFactory(servletContext); servletContext.setAttribute(ATTR_JSP_TAGLIBS_MODEL, taglibs); hashModel.putUnlistedModel(FreemarkerServlet.KEY_APPLICATION, newServletContextModel); hashModel.putUnlistedModel(FreemarkerServlet.KEY_APPLICATION_PRIVATE, newServletContextModel); hashModel.putUnlistedModel(FreemarkerServlet.KEY_JSP_TAGLIBS, taglibs); HttpRequestHashModel requestModel = new HttpRequestHashModel(request, response, wrapper); request.setAttribute(ATTR_REQUEST_MODEL, requestModel); hashModel.putUnlistedModel(FreemarkerServlet.KEY_REQUEST_PRIVATE, requestModel); return hashModel; }
Example #6
Source File: FreeMarkerInlineRenderBootstrap.java From rice with Educational Community License v2.0 | 6 votes |
/** * Initialize FreeMarker elements after servlet context and FreeMarker configuration have both * been populated. */ private static void finishConfig() { if (freeMarkerConfig != null && servletContext != null) { taglibFactory = new TaglibFactory(servletContext); objectWrapper = freeMarkerConfig.getObjectWrapper(); if (objectWrapper == null) { objectWrapper = ObjectWrapper.DEFAULT_WRAPPER; } GenericServlet servlet = new ServletAdapter(); try { servlet.init(new DelegatingServletConfig()); } catch (ServletException ex) { throw new BeanInitializationException("Initialization of GenericServlet adapter failed", ex); } servletContextHashModel = new ServletContextHashModel(servlet, ObjectWrapper.DEFAULT_WRAPPER); LOG.info("Freemarker configuration complete"); } }
Example #7
Source File: FreeMarkerInlineRenderBootstrap.java From rice with Educational Community License v2.0 | 2 votes |
/** * Get the servlet context hash model for use in the component rendering phase. * * @return The servlet context hash model for use in the component rendering phase. */ public static ServletContextHashModel getServletContextHashModel() { return servletContextHashModel; }