Package org.apache.velocity.tools.view.context

Examples of org.apache.velocity.tools.view.context.ChainedContext


                                         HttpServletResponse response)
    {
        ViewToolContext ctx;
        if (this.deprecationSupportMode)
        {
            ctx = new ChainedContext(velocity, request, response, servletContext);
        }
        else
        {
            ctx = new ViewToolContext(velocity, request, response, servletContext);
        }
View Full Code Here


        }

        // http://jira.dotmarketing.net/browse/DOTCMS-2917

    //get the context from the request if possible
        ChainedContext context;
        if ( request.getAttribute( VelocityServlet.VELOCITY_CONTEXT ) != null && request.getAttribute( VelocityServlet.VELOCITY_CONTEXT ) instanceof ChainedContext ) {
            return (ChainedContext) request.getAttribute( "velocityContext" );
        } else {
            RequestWrapper rw = new RequestWrapper( request );
            if ( request.getAttribute( "User-Agent" ) != null && request.getAttribute( "User-Agent" ).equals( Constants.USER_AGENT_DOTCMS_BROWSER ) ) {
                rw.setCustomUserAgentHeader( Constants.USER_AGENT_DOTCMS_BROWSER );
            }
            context = new ChainedContext( ctx, getEngine(), rw, response, Config.CONTEXT );
        }

        context.put("context", context);
    Logger.debug(VelocityServlet.class, "ChainedContext=" + context);
    /*
     * if we have a toolbox manager, get a toolbox from it See
     * /WEB-INF/toolbox.xml
     */
    context.setToolbox(getToolboxManager().getToolboxContext(context));


    // put the list of languages on the page
    context.put("languages", getLanguages());
    if(!UtilMethods.isSet(request.getAttribute(WebKeys.HTMLPAGE_LANGUAGE)))
        context.put("language", (String) request.getSession().getAttribute(com.dotmarketing.util.WebKeys.HTMLPAGE_LANGUAGE));
    else
        context.put("language", request.getAttribute(WebKeys.HTMLPAGE_LANGUAGE));

   
    try {
      Host host;
      host = WebAPILocator.getHostWebAPI().getCurrentHost(request);
      context.put("host", host);
    } catch (Exception e) {
      Logger.error(VelocityUtil.class,e.getMessage(),e);
    }
   
    context.put("pdfExport", false);
    com.liferay.portal.model.User user = null;

    try {
      user = (com.liferay.portal.model.User) request.getSession().getAttribute(com.dotmarketing.util.WebKeys.CMS_USER);
      context.put("user", user);
    } catch (Exception nsue) {
      Logger.error(VelocityServlet.class, nsue.getMessage(), nsue);
    }
    VelocityServlet.velocityCtx.set(context);
    return context;
View Full Code Here

TOP

Related Classes of org.apache.velocity.tools.view.context.ChainedContext

Copyright © 2018 www.massapicom. 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.