Package com.opensymphony.module.sitemesh

Examples of com.opensymphony.module.sitemesh.Page


        Config c = new Config(new MockServletConfig(context));
        m.init(c, null, null);
        HTMLPageParser parser = new HTMLPageParser();
        String html = "<html><head><title>Test title</title></head><body>here is the body</body></html>";

        Page page = parser.parse(html.toCharArray());
        Decorator d = m.getDecorator(request, page);
        assertNotNull(d);
        assertEquals("/layouts/test2/testAction.gsp", d.getPage());
        assertEquals("test2/testAction", d.getName());
    }
View Full Code Here


        Config c = new Config(new MockServletConfig(context));
        m.init(c, null, null);
        HTMLPageParser parser = new HTMLPageParser();
        String html = "<html><head><title>Test title</title></head><body>here is the body</body></html>";

        Page page = parser.parse(html.toCharArray());
        Decorator d = m.getDecorator(request, page);
        assertNotNull(d);
        assertEquals("/layouts/mylayout.gsp", d.getPage());
        assertEquals("mylayout", d.getName());
    }
View Full Code Here

    {
        Writer writer = new NullWriter();
        long start = System.currentTimeMillis();
        for (int i = 0; i < times; i++)
        {
            Page page = parser.parse(new DefaultSitemeshBuffer(data));
            page.writeBody(writer);
        }
        long finish = System.currentTimeMillis();
        long time = finish - start;
        System.out.println(name + " total: " + time + "ms");
        System.out.println(name + " average: " + (double) time / (double) times + "ms");
View Full Code Here

                "    <div>Bye</div>\n" +
                "  </body>\n" +
                "</html>";

        PageParser parser = new DivExtractingPageParser();
        Page page = parser.parse(new DefaultSitemeshBuffer(input.toCharArray()));

        String expectedBody = "" +
                "    <sitemesh:multipass id=\"div.one\"/>\n" +
                "    Blah\n" +
                "    <sitemesh:multipass id=\"div.two\"/>\n" +
                "    <div>Bye</div>\n";
        assertEquals("Title", page.getTitle());
        assertEquals(expectedBody.trim(), page.getBody().trim());
        assertEquals("<div id='one'>Hello</div>", page.getProperty("div.one"));
        assertEquals("<div id='two'>World<br><div id=inner>Great</div></div>", page.getProperty("div.two"));
    }
View Full Code Here

    public void testContentSanity() throws Exception {
        String input = (String) blocks.get("INPUT");
        final char[] chars = input.toCharArray();
        final char[] bigChars = new char[chars.length * 2 + 10]; // make it bigger
        System.arraycopy(chars, 0, bigChars, 0, chars.length);
        Page bigPage = parser.parse(new DefaultSitemeshBuffer(bigChars, chars.length));

        assertEquals(bigPage.getPage(), page.getPage());
    }
View Full Code Here

        }
    }

    public int doEndTag() {
        try {
            Page page = getPage();
            String propertyValue = page.getProperty(propertyName);

            if (propertyValue == null || propertyValue.trim().length() == 0)
                propertyValue = defaultValue;

            if (propertyValue != null) {
View Full Code Here

    /**
     * Return the Page object from the PAGE scope. If this is found in REQUEST scope
     * instead, it will be moved into PAGE scope - to handle multi-level includes.
     */
    protected Page getPage() {
        Page p = (Page)pageContext.getAttribute(PAGE, PageContext.PAGE_SCOPE);

        if (p == null) {
            p = (Page)pageContext.getAttribute(PAGE, PageContext.REQUEST_SCOPE);
            if (p == null) {
                pageContext.removeAttribute(PAGE, PageContext.PAGE_SCOPE);
View Full Code Here

import com.opensymphony.module.sitemesh.Page;

public class ExtractPropertyTag extends PropertyTag {

    public int doEndTag() {
        Page page = getPage();
        page.addProperty("_sitemesh.removefrompage." + getProperty(), "true");
        return super.doEndTag();
    }
View Full Code Here

TOP

Related Classes of com.opensymphony.module.sitemesh.Page

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.