Examples of Decorator


Examples of com.calclab.suco.client.ioc.Decorator

public class DecoratorTests {

    @SuppressWarnings("unchecked")
    @Test
    public void testChain() {
  final Decorator d1 = mock(Decorator.class);
  final Decorator d2 = mock(Decorator.class);
  final Chain chain = new Chain(d1, d2);
  chain.decorate(null, null);
  verify(d1).decorate((Class) anyObject(), (Provider) anyObject());
    }
View Full Code Here

Examples of com.calclab.suco.client.ioc.Decorator

  verify(container).registerProvider(same(NoDecoration.instance), eq(Object.class), same(f1));
    }

    @Test
    public void shouldRegisterProviderWithDecorator() {
  final Decorator d = NoDecoration.instance;
  final Class<Object> cType = Object.class;
  final Provider<Object> provider = TestHelper.provider();
  builder.register(d, cType, provider);
  verify(container).registerProvider(d, cType, provider);
    }
View Full Code Here

Examples of com.calclab.suco.client.ioc.Decorator

public class DecoratorTests {

    @SuppressWarnings("unchecked")
    @Test
    public void testChain() {
  final Decorator d1 = mock(Decorator.class);
  final Decorator d2 = mock(Decorator.class);
  final Chain chain = new Chain(d1, d2);
  chain.decorate(null, null);
  verify(d1).decorate((Class) anyObject(), (Provider) anyObject());
    }
View Full Code Here

Examples of com.calclab.suco.client.ioc.Decorator

  verify(container).registerProvider(same(NoDecoration.instance), eq(Object.class), same(f1));
    }

    @Test
    public void shouldRegisterProviderWithDecorator() {
  final Decorator d = NoDecoration.instance;
  final Class<Object> cType = Object.class;
  final Provider<Object> provider = TestHelper.provider();
  builder.register(d, cType, provider);
  verify(container).registerProvider(d, cType, provider);
    }
View Full Code Here

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

Examples of com.opensymphony.module.sitemesh.Decorator

            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

Examples of com.opensymphony.module.sitemesh.Decorator

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

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

Examples of com.opensymphony.module.sitemesh.Decorator

    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

Examples of com.opensymphony.module.sitemesh.Decorator

    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

Examples of com.opensymphony.module.sitemesh.Decorator

    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
TOP
Copyright © 2018 www.massapi.com. 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.