private void _addTaglibSupportFTL(Map<String, Object> contextObjects, PageContext pageContext)
      throws Exception {

    // FreeMarker servlet application

    final Servlet servlet = (Servlet) pageContext.getPage();

    GenericServlet genericServlet = null;

    if (servlet instanceof GenericServlet) {
      genericServlet = (GenericServlet) servlet;
    } else {
      genericServlet = new GenericServletWrapper(servlet);

      genericServlet.init(pageContext.getServletConfig());
    }

    ServletContextHashModel servletContextHashModel =
        new ServletContextHashModel(genericServlet, ObjectWrapper.DEFAULT_WRAPPER);

    contextObjects.put(
        PortletDisplayTemplateConstants.FREEMARKER_SERVLET_APPLICATION, servletContextHashModel);

    // FreeMarker servlet request

    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();

    HttpRequestHashModel requestHashModel =
        new HttpRequestHashModel(request, response, ObjectWrapper.DEFAULT_WRAPPER);

    contextObjects.put(
        PortletDisplayTemplateConstants.FREEMARKER_SERVLET_REQUEST, requestHashModel);

    // Taglib Liferay hash

    TemplateHashModel taglibLiferayHash =
        FreeMarkerTaglibFactoryUtil.createTaglibFactory(pageContext.getServletContext());

    contextObjects.put(PortletDisplayTemplateConstants.TAGLIB_LIFERAY_HASH, taglibLiferayHash);
  }
Example #2
0
 @Override
 public Object getPage() {
   return parentPageContext.getPage();
 }