Examples of RenderCommand


Examples of org.apache.tapestry5.runtime.RenderCommand

        configuration.add(CoercionTuple.create(Renderable.class, RenderCommand.class,
                new Coercion<Renderable, RenderCommand>()
                {
                    public RenderCommand coerce(final Renderable input)
                    {
                        return new RenderCommand()
                        {
                            public void render(MarkupWriter writer, RenderQueue queue)
                            {
                                input.render(writer);
                            }
View Full Code Here

Examples of org.apache.tapestry5.runtime.RenderCommand

     *         if true, add "last" attribute to the LI element
     * @return command to render the node
     */
    private RenderCommand toRenderCommand(final TreeNode node, final boolean isLast)
    {
        return new RenderCommand()
        {
            public void render(MarkupWriter writer, RenderQueue queue)
            {
                // Inform the component's container about what value is being rendered
                // (this may be necessary to generate the correct label for the node).
                Tree.this.node = node;

                value = node.getValue();

                boolean isLeaf = node.isLeaf();

                writer.element("li");

                if (isLast)
                {
                    writer.attributes("class", "last");
                }

                if (isLeaf)
                {
                    writer.getElement().attribute("class", "leaf-node");
                }

                Element e = writer.element("span", "class", "tree-icon");

                if (!isLeaf && !node.getHasChildren())
                {
                    e.addClassName("empty-node");
                }

                boolean hasChildren = !isLeaf && node.getHasChildren();
                boolean expanded = hasChildren && expansionModel.isExpanded(node);

                writer.attributes("data-node-id", node.getId());

                if (expanded)
                {
                    // Inform the client side, so it doesn't try to fetch it a second time.
                    e.addClassName("tree-expanded");
                }

                writer.end(); // span.tree-icon

                // From here on in, we're pushing things onto the queue. Remember that
                // execution order is reversed from order commands are pushed.

                queue.push(RENDER_CLOSE_TAG); // li

                if (expanded)
                {
                    queue.push(new RenderNodes(node.getChildren()));
                }

                queue.push(RENDER_CLOSE_TAG);
                final RenderCommand startHeartbeat = new RenderCommand() {

                    @Override
                    public void render(MarkupWriter writer, RenderQueue queue) {
                        heartbeat.begin();
                    }
                };

                final RenderCommand endHeartbeat = new RenderCommand() {

                    @Override
                    public void render(MarkupWriter writer, RenderQueue queue) {
                        heartbeat.end();
                    }
View Full Code Here

Examples of org.apache.tapestry5.runtime.RenderCommand

    public AjaxResponseRenderer addRender(String clientId, Object renderer)
    {
        assert InternalUtils.isNonBlank(clientId);
        assert renderer != null;

        RenderCommand command = typeCoercer.coerce(renderer, RenderCommand.class);

        addFilter(new SingleZonePartialRendererFilter(clientId, command, queue, ajaxFormUpdateController));

        return this;
    }
View Full Code Here

Examples of org.apache.tapestry5.runtime.RenderCommand

        queue.push(command);
    }

    public void run(MarkupWriter writer)
    {
        RenderCommand command = null;

        boolean traceEnabled = logger.isTraceEnabled(TapestryMarkers.RENDER_COMMANDS);
        boolean debugEnabled = logger.isDebugEnabled();

        long startNanos = -1l;

        if (debugEnabled)
        {
            startNanos = System.nanoTime();
        }
        int commandCount = 0;
        int maxDepth = 0;

        // Seems to make sense to use one try/finally around the whole processInbound, rather than
        // around each call to render() since the end result (in a failure scenario) is the same.

        try
        {
            while (!queue.isEmpty())
            {
                maxDepth = Math.max(maxDepth, queue.getDepth());

                command = queue.pop();

                commandCount++;

                if (traceEnabled) logger.trace(TapestryMarkers.RENDER_COMMANDS, "Executing: {}", command);

                command.render(writer, this);
            }
        } catch (RuntimeException ex)
        {
            String message = String.format("Render queue error in %s: %s", command, ExceptionUtils.toMessage(ex));
View Full Code Here

Examples of org.apache.tapestry5.runtime.RenderCommand

        configuration.add(CoercionTuple.create(Renderable.class, RenderCommand.class,
                new Coercion<Renderable, RenderCommand>()
                {
                    public RenderCommand coerce(final Renderable input)
                    {
                        return new RenderCommand()
                        {
                            public void render(MarkupWriter writer, RenderQueue queue)
                            {
                                input.render(writer);
                            }
View Full Code Here

Examples of org.apache.tapestry5.runtime.RenderCommand

public class RenderQueueImplTest extends InternalBaseTestCase
{
    @Test
    public void run_commands()
    {
        final RenderCommand command2 = newMock(RenderCommand.class);
        RenderCommand command1 = new RenderCommand()
        {
            public void render(MarkupWriter writer, RenderQueue queue)
            {
                queue.push(command2);
            }
View Full Code Here

Examples of org.apache.tapestry5.runtime.RenderCommand

        ComponentResources bar = mockInternalComponentResources();
        ComponentResources baz = mockInternalComponentResources();

        final RuntimeException t = new RuntimeException("Oops.");

        RenderCommand rc = new RenderCommand()
        {

            public void render(MarkupWriter writer, RenderQueue queue)
            {
                throw t;
View Full Code Here

Examples of org.apache.tapestry5.runtime.RenderCommand

        if (!callback.isAborted()) return;

        // Here's where it gets very, very tricky.

        final RenderCommand rootRenderCommand = pageRenderQueue.getRootRenderCommand();

        final String formId = request.getParameter(FORMID_PARAMETER);

        if (InternalUtils.isBlank(formId))
            throw new RuntimeException(String.format(
View Full Code Here

Examples of org.apache.tapestry5.runtime.RenderCommand

public class CompositeRenderCommandTest extends InternalBaseTestCase
{
    @DataProvider(name = "nyi")
    public Object[][] nyi_data()
    {
        RenderCommand push = new RenderCommand()
        {
            public void render(MarkupWriter writer, RenderQueue queue)
            {
                queue.push(null);
            }
        };

        RenderCommand startComponent = new RenderCommand()
        {
            public void render(MarkupWriter writer, RenderQueue queue)
            {
                queue.startComponent(null);
            }
        };

        RenderCommand endComponent = new RenderCommand()
        {
            public void render(MarkupWriter writer, RenderQueue queue)
            {
                queue.endComponent();
            }
View Full Code Here

Examples of org.apache.tapestry5.runtime.RenderCommand

        replay();

        PageElementFactory factory = new PageElementFactoryImpl(source, resolver, null, null, null);
        AttributeToken token = new AttributeToken(null, "name", "value", l);

        RenderCommand element = factory.newAttributeElement(null, token);

        writer.element("root");

        element.render(writer, queue);

        verify();

        assertEquals(writer.toString(), "<?xml version=\"1.0\"?>\n<root name=\"value\"/>");
    }
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.