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

Examples of org.apache.velocity.tools.view.tools.LinkTool


  @Override
  public void addVelocityTools(VelocityContext context) {
    context.put("date", new MyDateTool(getBusiness().getTimeZone()));
    context.put("esc", new MyEscTool());
    context.put("link", new LinkTool());
    context.put("list", new ListTool());
    context.put("number", new NumberTool());
    context.put("render", new RenderTool());
    context.put("sorter", new SortTool());
    context.put("math", new MathTool());
View Full Code Here


        assertTrue(context.get("map") instanceof HashMap);
        assertTrue(context.get("date") instanceof DateTool);
        assertTrue(context.get("math") instanceof MathTool);

        assertTrue(context.get("link") instanceof LinkTool);
        LinkTool linkTool = (LinkTool) context.get("link");
        assertNotNull(linkTool.getContextURL());

        assertTrue(context.get("link2") instanceof LinkTool);
        LinkTool linkTool2 = (LinkTool) context.get("link2");
        assertNotNull(linkTool2.getContextURL());
      }
    };

    vv.setUrl(templateName);
    vv.setApplicationContext(wac);
View Full Code Here

        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")
            .addQueryData("foo", "bar")
            .addQueryData("bar", "baz")
            .addAllParameters()
            .toString();
View Full Code Here

        HashMap params = new HashMap();
        params.put("a", new String[] { "a", "b", "c" });
        InvocationHandler handler = new ServletAdaptor("/test", params);
        ViewContext vc = createViewContext(handler);

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

        String url = link.setRelative("/target")
            .addQueryData("foo", "bar")
            .addQueryData("bar", "baz")
            .addAllParameters()
            .toString();
View Full Code Here

        params.put("b", "c");
        InvocationHandler handler = new ServletAdaptor("/test", params);

        ViewContext vc = createViewContext(handler);

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

        String url = link.setRelative("/target")
            .addQueryData("foo", "bar")
            .addQueryData("bar", "baz")
            .addIgnore("b")
            .addAllParameters()
            .toString();
View Full Code Here

        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")
            .addAllParameters()
            .addQueryData("foo", "bar")
            .addQueryData("bar", "baz")
            .toString();
View Full Code Here

        params.put("a", "b");
        InvocationHandler handler = new ServletAdaptor("/test", params);

        ViewContext vc = createViewContext(handler);

        LinkTool link = new LinkTool();
        link.init(vc);
        link.configure(Collections.singletonMap(LinkTool.AUTO_IGNORE_PARAMETERS_KEY, Boolean.FALSE));

        String url = link.setRelative("/target")
            .addQueryData("a", "c")
            .addAllParameters()
            .toString();

        Assert.assertEquals("/test/target?a=c&a=b", url);
View Full Code Here

        params.put("a", "b");
        InvocationHandler handler = new ServletAdaptor("/test", params);

        ViewContext vc = createViewContext(handler);

        LinkTool link = new LinkTool();
        link.init(vc);
        link.configure(Collections.singletonMap(LinkTool.AUTO_IGNORE_PARAMETERS_KEY, Boolean.FALSE));

        String url = link.setRelative("/target")
            .addAllParameters()
            .addQueryData("a", "c")
            .toString();

        Assert.assertEquals("/test/target?a=b&a=c", url);
View Full Code Here

        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")
            .addQueryData("a", "c")
            .toString();

        Assert.assertEquals("/test/target?a=c", url);
    }
View Full Code Here

        params.put("a", new String[] { "a", "b", "c" } );
        InvocationHandler handler = new ServletAdaptor("/test", params);

        ViewContext vc = createViewContext(handler);

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

        String url = link.setRelative("/target")
            .addQueryData("a", "d")
            .addAllParameters()
            .toString();

        Assert.assertEquals("/test/target?a=d", url);
View Full Code Here

TOP

Related Classes of org.apache.velocity.tools.view.tools.LinkTool

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.