Package com.opensymphony.module.sitemesh

Examples of com.opensymphony.module.sitemesh.Decorator


            Page page = parsePage(request, response);

            if (page != null) {
                page.setRequest(request);

                Decorator decorator = factory.getDecoratorMapper().getDecorator(request, page);
                if (decorator != null && decorator.getPage() != null) {
                    applyDecorator(page, decorator, request, response);
                    page = null;
                    return;
                }
View Full Code Here


            if (node.jjtGetNumChildren() == 3)
                bodyNode = 2;
            node.jjtGetChild(bodyNode).render(adapter, bodyContent);

            Factory factory = PortletContext.getContext().getSiteMeshFactory();
            Decorator decorator = factory.getDecoratorMapper().getNamedDecorator(request, decoratorName);
            if (decorator != null) {
                com.opensymphony.module.sitemesh.PageParser parser = factory.getPageParser("text/html");
                HTMLPage page = (HTMLPage) ((FastPageParser) parser).parse(new StringReader(bodyContent.toString()));
                Context context = VelocityManager.getInstance()
                        .createContext(ActionContext.getContext().getValueStack(), request, response);
                context.put("page", page);
                if (node.jjtGetNumChildren() == 3)
                    context.put("title", (String) node.jjtGetChild(1).value(adapter));
                else
                    context.put("title", page.getTitle());
                StringWriter buffer = new StringWriter();
                page.writeBody(OutputConverter.getWriter(buffer));
                context.put("body", buffer.toString());
                buffer = new StringWriter();
                page.writeHead(OutputConverter.getWriter(buffer));
                context.put("head", buffer.toString());
                context.put("params", params);
                writer.write(VelocityUtils.getRenderedTemplate(decorator.getPage(), context));
            } else {
                throw new IOException("could not find decorator with name: " + decoratorName);
            }
            flag = true;
            stack.pop();
View Full Code Here

      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }

    Decorator result = getNamedDecorator(request, name);
    return ((result == null) ? super.getDecorator(request, page) : result);
  }
View Full Code Here

    super.init(config, properties, parent);
    decoratorParameter = properties.getProperty("decorator.parameter", "decorator");
  }

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

    if (decorator != null) {
      result = getNamedDecorator(request, decorator);
    }
View Full Code Here

    public Decorator getDecorator(HttpServletRequest request, Page page) {
        if (groovyPageLayoutFinder == null) {
            return super.getDecorator(request, page);
        }
       
        Decorator layout = groovyPageLayoutFinder.findLayout(request, page);
        if (layout != null) {
            return layout;
        }
        layout = parent != null ? super.getDecorator(request, page) : null;
        if (layout == null || layout.getPage() == null) {
            layout = new GrailsNoDecorator();
        }
        return layout;
    }
View Full Code Here

    public Decorator getNamedDecorator(HttpServletRequest request, String name) {
        if (groovyPageLayoutFinder == null) {
            return super.getNamedDecorator(request, name);
        }
       
        Decorator layout = groovyPageLayoutFinder.getNamedDecorator(request, name);
        if (layout != null) {
            return layout;
        }
        layout = parent != null ? super.getNamedDecorator(request, name) : null;
        if (layout == null || layout.getPage() == null) {
            layout = new GrailsNoDecorator();
        }
        return layout;
    }
View Full Code Here

            if (layoutName == null) {
                layoutName = page.getProperty("meta.layout");
            }

            Decorator d = null;

            if (GrailsStringUtils.isBlank(layoutName)) {
                GroovyObject controller = (GroovyObject)request.getAttribute(GrailsApplicationAttributes.CONTROLLER);
                if (controller != null) {
                    String controllerName = (String)controller.getProperty(ControllerDynamicMethods.CONTROLLER_NAME_PROPERTY);
View Full Code Here

        }
        catch (Exception e) {
            throw new RuntimeException("Unable to resolve view", e);
        }

        Decorator d = null;
        if (view != null) {
            d = createDecorator(name, view);
        }

        if (cacheEnabled) {
View Full Code Here

        return d;
    }

    private Decorator resolveDecorator(HttpServletRequest request, GroovyObject controller, String controllerName,
            String actionUri) {
        Decorator d = null;

        Object layoutProperty = GrailsClassUtils.getStaticPropertyValue(controller.getClass(), "layout");
        if (layoutProperty instanceof CharSequence) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("layout property found in controller, looking for template named " + layoutProperty);
View Full Code Here

        m.init(c, null, null);
        HTMLPageParser parser = new HTMLPageParser();
        String html = "<html><head><title>Test title</title><meta name=\"layout\" content=\"test\"></meta></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

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.