@Override protected Context createVelocityContext(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { org.apache.velocity.tools.view.context.ChainedContext context = new org.apache.velocity.tools.view.context.ChainedContext( new VelocityContext(model), getVelocityEngine(), request, response, getServletContext()); if (getToolboxConfigLocation() != null) { setContextToolbox(context); } return context; }
/** * Overridden to create a ChainedContext, which is part of the view package * of Velocity Tools, as special context. ChainedContext is needed for * initialization of ViewTool instances. * @see #initTool */ @Override protected Context createVelocityContext( Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { // Create a ChainedContext instance. ChainedContext velocityContext = new ChainedContext( new VelocityContext(model), getVelocityEngine(), request, response, getServletContext()); // Load a Velocity Tools toolbox, if necessary. if (getToolboxConfigLocation() != null) { ToolboxManager toolboxManager = ServletToolboxManager.getInstance( getServletContext(), getToolboxConfigLocation()); Map<String,Object> toolboxContext = toolboxManager.getToolbox(velocityContext); velocityContext.setToolbox(toolboxContext); } return velocityContext; }
@SuppressWarnings("unchecked") private void setContextToolbox( org.apache.velocity.tools.view.context.ChainedContext context) { org.apache.velocity.tools.view.ToolboxManager toolboxManager = org.apache.velocity.tools.view.servlet.ServletToolboxManager .getInstance(getToolboxConfigFileAwareServletContext(), getToolboxConfigLocation()); Map<String, Object> toolboxContext = toolboxManager.getToolbox(context); context.setToolbox(toolboxContext); }
/** * Overridden to create a ChainedContext, which is part of the view package * of Velocity Tools, as special context. ChainedContext is needed for * initialization of ViewTool instances. * @see #initTool */ @Override protected Context createVelocityContext( Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { // Create a ChainedContext instance. ChainedContext velocityContext = new ChainedContext( new VelocityContext(model), getVelocityEngine(), request, response, getServletContext()); // Load a Velocity Tools toolbox, if necessary. if (getToolboxConfigLocation() != null) { ToolboxManager toolboxManager = ServletToolboxManager.getInstance( getServletContext(), getToolboxConfigLocation()); Map<String, Object> toolboxContext = toolboxManager.getToolbox(velocityContext); velocityContext.setToolbox(toolboxContext); } return velocityContext; }
@SuppressWarnings("unchecked") private void setContextToolbox( org.apache.velocity.tools.view.context.ChainedContext context) { org.apache.velocity.tools.view.ToolboxManager toolboxManager = org.apache.velocity.tools.view.servlet.ServletToolboxManager .getInstance(getToolboxConfigFileAwareServletContext(), getToolboxConfigLocation()); Map<String, Object> toolboxContext = toolboxManager.getToolbox(context); context.setToolbox(toolboxContext); }
/** * Overridden to create a ChainedContext, which is part of the view package * of Velocity Tools, as special context. ChainedContext is needed for * initialization of ViewTool instances. * @see #initTool */ @Override protected Context createVelocityContext( Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { // Create a ChainedContext instance. ChainedContext velocityContext = new ChainedContext( new VelocityContext(model), getVelocityEngine(), request, response, getServletContext()); // Load a Velocity Tools toolbox, if necessary. if (getToolboxConfigLocation() != null) { ToolboxManager toolboxManager = ServletToolboxManager.getInstance( getServletContext(), getToolboxConfigLocation()); Map<?, ?> toolboxContext = toolboxManager.getToolbox(velocityContext); velocityContext.setToolbox(toolboxContext); } return velocityContext; }
@Override protected Context createVelocityContext(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { org.apache.velocity.tools.view.context.ChainedContext context = new org.apache.velocity.tools.view.context.ChainedContext( new VelocityContext(model), getVelocityEngine(), request, response, getServletContext()); if (getToolboxConfigLocation() != null) { setContextToolbox(context); } return context; }
ChainedContext chained = new ChainedContext(context, req, res, ctx); chained.setToolbox(toolboxManager.getToolboxContext(chained)); return chained; } else {