Package org.apache.velocity.tools.view

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



    protected void initializeView()
    {
        // get the VelocityView for this app
        VelocityView view =
            ServletUtils.getVelocityView(this.pageContext.getServletConfig());

        // now make a Context
        ViewToolContext context =
            new JspToolContext(view.getVelocityEngine(), this.pageContext);

        view.prepareToolboxes((HttpServletRequest)this.pageContext.getRequest());
        view.prepareContext(context);

        setVelocityView(view);
        setViewToolContext(context);
    }
View Full Code Here


        return (getBodyContent() != null || getTemplate() != null);
    }

    protected void renderContent(Writer out) throws Exception
    {
        VelocityView view = getVelocityView();
        VelocityEngine engine = view.getVelocityEngine();

        if (getTemplate() != null)
        {
            ViewToolContext context = getViewToolContext();

            // get the actual Template
            Template template = view.getTemplate(getTemplate());

            if (getBodyContent() != null)
            {
                context.put(getBodyContentKey(), getRenderedBody());
            }
View Full Code Here

     * Tests {@link VelocityRenderer#render(String, org.apache.tiles.request.Request)}.
     * @throws IOException If something goes wrong.
     */
    @Test
    public void testRender() throws IOException {
        VelocityView view = createMock(VelocityView.class);
        ServletRequest request = createMock(ServletRequest.class);
        HttpServletRequest httpRequest = createMock(HttpServletRequest.class);
        HttpServletResponse response = createMock(HttpServletResponse.class);
        ViewToolContext context = createMock(ViewToolContext.class);
        Template template = createMock(Template.class);
        Writer writer = createMock(Writer.class);

        expect(request.getRequest()).andReturn(httpRequest);
        expect(request.getResponse()).andReturn(response);
        expect(view.createContext(httpRequest, response)).andReturn(context);
        expect(view.getTemplate("/test.vm")).andReturn(template);
        expect(request.getWriter()).andReturn(writer);
        view.merge(template, context, writer);

        replay(view, request, httpRequest, response, context, template, writer);
        Renderer renderer = new VelocityRenderer(view);
        renderer.render("/test.vm", request);
        verify(view, request, httpRequest, response, context, template, writer);
View Full Code Here

     * Tests {@link VelocityRenderer#render(String, org.apache.tiles.request.Request)}.
     * @throws IOException If something goes wrong.
     */
    @Test(expected = CannotRenderException.class)
    public void testRenderException() throws IOException {
        VelocityView view = createMock(VelocityView.class);
        ServletRequest request = createMock(ServletRequest.class);

        replay(view, request);
        Renderer renderer = new VelocityRenderer(view);
        try {
View Full Code Here

     * {@link VelocityRenderer#isRenderable(String, org.apache.tiles.request.Request)}
     * .
     */
    @Test
    public void testIsRenderable() {
        VelocityView view = createMock(VelocityView.class);
        replay(view);
        Renderer renderer = new VelocityRenderer(view);
        assertTrue(renderer.isRenderable("/my/template.vm", null));
        assertFalse(renderer.isRenderable("my/template.vm", null));
        assertFalse(renderer.isRenderable("/my/template.jsp", null));
View Full Code Here

     * Creates the Velocity renderer.
     *
     * @return The Velocity renderer.
     */
    public VelocityRenderer build() {
        VelocityView velocityView = new VelocityView(
                new ApplicationContextJeeConfig(applicationContext, params));
        return new VelocityRenderer(velocityView);
    }
View Full Code Here


    protected void initializeView()
    {
        // get the VelocityView for this app
        VelocityView view =
            ServletUtils.getVelocityView(this.pageContext.getServletConfig());

        // now make a Context
        ViewToolContext context =
            new JspToolContext(view.getVelocityEngine(), this.pageContext);

        view.prepareToolboxes((HttpServletRequest)this.pageContext.getRequest());
        view.prepareContext(context);

        setVelocityView(view);
        setViewToolContext(context);
    }
View Full Code Here

    protected void renderContent(Writer out) throws Exception
    {
        if (getTemplate() != null)
        {
            VelocityView view = getVelocityView();
            ViewToolContext context = getViewToolContext();

            // get the actual Template
            Template template = view.getTemplate(getTemplate());

            if (getBodyContent() != null)
            {
                context.put(getBodyContentKey(), getRenderedBody());
            }
View Full Code Here

     * Tests {@link VelocityRenderer#render(String, org.apache.tiles.request.Request)}.
     * @throws IOException If something goes wrong.
     */
    @Test
    public void testRender() throws IOException {
        VelocityView view = createMock(VelocityView.class);
        ServletRequest request = createMock(ServletRequest.class);
        HttpServletRequest httpRequest = createMock(HttpServletRequest.class);
        HttpServletResponse response = createMock(HttpServletResponse.class);
        ViewToolContext context = createMock(ViewToolContext.class);
        Template template = createMock(Template.class);
        Writer writer = createMock(Writer.class);

        expect(request.getRequest()).andReturn(httpRequest);
        expect(request.getResponse()).andReturn(response);
        expect(view.createContext(httpRequest, response)).andReturn(context);
        expect(view.getTemplate("/test.vm")).andReturn(template);
        expect(request.getWriter()).andReturn(writer);
        view.merge(template, context, writer);

        replay(view, request, httpRequest, response, context, template, writer);
        Renderer renderer = new VelocityRenderer(view);
        renderer.render("/test.vm", request);
        verify(view, request, httpRequest, response, context, template, writer);
View Full Code Here

     * Tests {@link VelocityRenderer#render(String, org.apache.tiles.request.Request)}.
     * @throws IOException If something goes wrong.
     */
    @Test(expected = CannotRenderException.class)
    public void testRenderException() throws IOException {
        VelocityView view = createMock(VelocityView.class);
        ServletRequest request = createMock(ServletRequest.class);

        replay(view, request);
        Renderer renderer = new VelocityRenderer(view);
        try {
View Full Code Here

TOP

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

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.