Package com.opensymphony.module.sitemesh

Examples of com.opensymphony.module.sitemesh.Decorator


        m.init(c, null, null);
        HTMLPageParser parser = new HTMLPageParser();
        String html = "<html><head><title>Foo 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/application.gsp", d.getPage());
        assertEquals("application", d.getName());
    }
View Full Code Here


        m.init(c, null, null);
        HTMLPageParser parser = new HTMLPageParser();
        String html = "<html><head><title>Foo 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/application.gsp", d.getPage());
        assertEquals("application", d.getName());
    }
View Full Code Here

            m.init(c, null, null);
            HTMLPageParser parser = new HTMLPageParser();
            String html = "<html><head><title>Foo 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/otherApplication.gsp", d.getPage());
            assertEquals("otherApplication", d.getName());
    }
View Full Code Here

        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/test.gsp", d.getPage());
        assertEquals("test", d.getName());
    }
View Full Code Here

        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

        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

    }

    public com.opensymphony.sitemesh.Decorator selectDecorator(Content content, SiteMeshContext context) {
        SiteMeshWebAppContext webAppContext = (SiteMeshWebAppContext) context;
        HttpServletRequest request = webAppContext.getRequest();
        Decorator decorator =
                decoratorMapper.getDecorator(request, new Content2HTMLPage(content, request));
        if (decorator == null || decorator.getPage() == null) {
            return new NoDecorator();
        } else {
            return new OldDecorator2NewStrutsVelocityDecorator(decorator);
        }
    }
View Full Code Here

        paramName = properties.getProperty("parameter.name", null);
        paramValue = properties.getProperty("parameter.value", null);
    }

    public Decorator getDecorator(HttpServletRequest request, Page page) {
        Decorator result = null;
        String decoratorParamValue = request.getParameter(decoratorParameter);

        if ((paramName == null || paramValue.equals(request.getParameter(paramName)))
            && decoratorParamValue != null && !decoratorParamValue.trim().equals("")) {
                result = getNamedDecorator(request, decoratorParamValue);
View Full Code Here

*
* @see com.opensymphony.module.sitemesh.DecoratorMapper
*/
public class InlineDecoratorMapper extends AbstractDecoratorMapper implements RequestConstants {
  public Decorator getDecorator(HttpServletRequest request, Page page) {
    Decorator result = null;
    if (request.getAttribute(DECORATOR) != null) {
      // Retrieve name of decorator to use from request
      String decoratorName = (String)request.getAttribute(DECORATOR);
      result = getNamedDecorator(request, decoratorName);
      if (result == null) throw new FactoryException("Cannot locate inline Decorator: " + decoratorName);
View Full Code Here

        initMap(properties);
    }

    public Decorator getDecorator(HttpServletRequest request, Page page) {
        try {
            Decorator result = null;
            final Decorator d = super.getDecorator(request, page);
            String path = modifyPath(d.getPage(), getExt(request.getHeader("User-Agent")));

            File decFile = new File(config.getServletContext().getRealPath(path));

            if (decFile.isFile()) {
                result = new DefaultDecorator(d.getName(), path, null) {
                    public String getInitParameter(String paramName) {
                        return d.getInitParameter(paramName);
                    }
                };
            }
            return result == null ? super.getDecorator(request, page) : result;
        }
View Full Code Here

TOP

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

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.