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

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


   * @see org.apache.velocity.tools.view.tools.ViewTool#init(java.lang.Object)
   */
  public void init(Object arg0) {
    //scope: request or session
    if(arg0 instanceof ViewContext){
      ViewContext viewContext = (ViewContext) arg0;
      request = viewContext.getRequest();
      response = viewContext.getResponse();
      context = viewContext.getServletContext();
      velocity = (VelocityContext)viewContext.getVelocityContext();
    }
    //scope: application
    else if(arg0 instanceof ServletContext){
      context = (ServletContext)arg0;
    }
View Full Code Here


     * @param initData the {@link ViewContext} for the current servlet request
     */
    public Map getToolbox(Object initData)
    {
        //we know the initData is a ViewContext
        ViewContext ctx = (ViewContext)initData;
        String requestPath = ServletUtils.getPath(ctx.getRequest());

        //create the toolbox map with the application tools in it
        Map toolbox = new HashMap(appTools);

        if (!sessionToolInfo.isEmpty())
        {
            HttpSession session = ctx.getRequest().getSession(createSession);
            if (session != null)
            {
                // allow only one thread per session at a time
                synchronized(getMutex(session))
                {
View Full Code Here

     * @param initData the {@link ViewContext} for the current servlet request
     */
    public Map getToolbox(Object initData)
    {
        //we know the initData is a ViewContext
        ViewContext ctx = (ViewContext)initData;
        String requestPath = ServletUtils.getPath(ctx.getRequest());

        //create the toolbox map with the application tools in it
        Map toolbox = new HashMap(appTools);

        if (!sessionToolInfo.isEmpty())
        {
            HttpSession session = ctx.getRequest().getSession(createSession);
            if (session != null)
            {
                // allow only one thread per session at a time
                synchronized(getMutex(session))
                {
View Full Code Here

     * @param obj the current ViewContext
     * @throws ClassCastException if the param is not a ViewContext
     */
    public void init(Object obj)
    {
        ViewContext context = (ViewContext)obj;
        HttpServletRequest request = context.getRequest();
        session = request.getSession(false);
        setup(request);
    }
View Full Code Here

        if (!(obj instanceof ViewContext))
        {
            throw new IllegalArgumentException("Tool can only be initialized with a ViewContext");
        }
        ViewContext context = (ViewContext)obj;
        this.request = context.getRequest();
        this.response = context.getResponse();
        this.application = context.getServletContext();   
    }
View Full Code Here

     * @param initData the {@link ViewContext} for the current servlet request
     */
    public ToolboxContext getToolboxContext(Object initData)
    {
        //we know the initData is a ViewContext
        ViewContext ctx = (ViewContext)initData;
       
        //create the toolbox map with the application tools in it
        Map toolbox = new HashMap(appTools);

        if (!sessionToolInfo.isEmpty())
        {
            HttpSession session = ctx.getRequest().getSession(createSession);

            if (session != null) {
                //synchronize session tool initialization to avoid potential
                //conflicts from multiple simultaneous requests in the same session
                synchronized(session)
View Full Code Here

        if (!(obj instanceof ViewContext))
        {
            throw new IllegalArgumentException("Tool can only be initialized with a ViewContext");
        }

        ViewContext context = (ViewContext)obj;
        HttpServletRequest request = context.getRequest();
        HttpSession session = request.getSession(false);
        ServletContext application = context.getServletContext();   

        this.resources = StrutsUtils.getMessageResources(application);
        this.locale = StrutsUtils.getLocale(request, session);
    }
View Full Code Here

        if (!(obj instanceof ViewContext))
        {
            throw new IllegalArgumentException("Tool can only be initialized with a ViewContext");
        }

        ViewContext context = (ViewContext)obj;
        this.request = context.getRequest();
        this.session = request.getSession(false);
        this.application = context.getServletContext();   

        resources = StrutsUtils.getMessageResources(application);
        locale = StrutsUtils.getLocale(request, session);
        errors = StrutsUtils.getActionErrors(request);
    }
View Full Code Here

        if (!(obj instanceof ViewContext))
        {
            throw new IllegalArgumentException("Tool can only be initialized with a ViewContext");
        }

        ViewContext context = (ViewContext)obj;
        this.request = context.getRequest();
        this.session = request.getSession(false);
    }
View Full Code Here

    public @Test void testAddAllParameters()
    {
        HashMap params = new HashMap();
        params.put("a", "b");
        InvocationHandler handler = new ServletAdaptor("/test", params);
        ViewContext vc = createViewContext(handler);

        LinkTool link = new LinkTool();
        link.init(vc);

        String url = link.setRelative("/target")
View Full Code Here

TOP

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

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.