Search in sources :

Example 6 with ServletContextHashModel

use of freemarker.ext.servlet.ServletContextHashModel in project entando-core by entando.

the class ControllerServlet method createModel.

@Override
protected TemplateModel createModel(ObjectWrapper wrapper, ServletContext servletContext, HttpServletRequest request, HttpServletResponse response) throws TemplateModelException {
    TemplateModel template = super.createModel(wrapper, servletContext, request, response);
    if (template instanceof AllHttpScopesHashModel) {
        AllHttpScopesHashModel hashModel = ((AllHttpScopesHashModel) template);
        ServletContextHashModel servletContextModel = (ServletContextHashModel) hashModel.get(KEY_APPLICATION);
        if (null == servletContextModel.getServlet()) {
            ServletContextHashModel newServletContextModel = new ServletContextHashModel(this, wrapper);
            servletContextModel = new ServletContextHashModel(this, wrapper);
            servletContext.setAttribute(ATTR_APPLICATION_MODEL, servletContextModel);
            TaglibFactory taglibs = new TaglibFactory(servletContext);
            servletContext.setAttribute(ATTR_JSP_TAGLIBS_MODEL, taglibs);
            hashModel.putUnlistedModel(KEY_APPLICATION, newServletContextModel);
            hashModel.putUnlistedModel(KEY_APPLICATION_PRIVATE, newServletContextModel);
        }
    }
    return template;
}
Also used : AllHttpScopesHashModel(freemarker.ext.servlet.AllHttpScopesHashModel) ServletContextHashModel(freemarker.ext.servlet.ServletContextHashModel) TaglibFactory(freemarker.ext.jsp.TaglibFactory) TemplateModel(freemarker.template.TemplateModel)

Aggregations

ServletContextHashModel (freemarker.ext.servlet.ServletContextHashModel)6 TaglibFactory (freemarker.ext.jsp.TaglibFactory)5 HttpRequestHashModel (freemarker.ext.servlet.HttpRequestHashModel)3 HttpSession (javax.servlet.http.HttpSession)3 AllHttpScopesHashModel (freemarker.ext.servlet.AllHttpScopesHashModel)2 HttpSessionHashModel (freemarker.ext.servlet.HttpSessionHashModel)2 TemplateModel (freemarker.template.TemplateModel)2 GenericServlet (javax.servlet.GenericServlet)2 ServletException (javax.servlet.ServletException)2 Delegator (org.apache.ofbiz.entity.Delegator)2 GenericValue (org.apache.ofbiz.entity.GenericValue)2 HttpRequestParametersHashModel (freemarker.ext.servlet.HttpRequestParametersHashModel)1 IOException (java.io.IOException)1 RequestDispatcher (javax.servlet.RequestDispatcher)1 ServletContext (javax.servlet.ServletContext)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 UtilTimer (org.apache.ofbiz.base.util.UtilTimer)1 GenericDelegator (org.apache.ofbiz.entity.GenericDelegator)1 GenericTransactionException (org.apache.ofbiz.entity.transaction.GenericTransactionException)1