Search in sources :

Example 1 with RenderCommand

use of org.apache.tapestry5.runtime.RenderCommand in project tapestry-5 by apache.

the class CompositeRenderCommandTest method render_queue_commands_nyi.

@Test(dataProvider = "nyi_data")
public void render_queue_commands_nyi(RenderCommand rc) {
    MarkupWriter writer = mockMarkupWriter();
    RenderQueue queue = mockRenderQueue();
    try {
        new CompositeRenderCommand(new RenderCommand[] { rc }).render(writer, queue);
        unreachable();
    } catch (IllegalStateException ex) {
    // Don't care about the message.
    }
}
Also used : RenderCommand(org.apache.tapestry5.runtime.RenderCommand) RenderQueue(org.apache.tapestry5.runtime.RenderQueue) MarkupWriter(org.apache.tapestry5.MarkupWriter) Test(org.testng.annotations.Test)

Example 2 with RenderCommand

use of org.apache.tapestry5.runtime.RenderCommand in project tapestry-5 by apache.

the class AjaxComponentInstanceEventResultProcessor method processResultValue.

public void processResultValue(Component value) throws IOException {
    ComponentResources resources = value.getComponentResources();
    boolean isPage = value == resources.getPage();
    String pageName = resources.getPageName();
    if (isPage) {
        // This will ultimately send a JSON response to redirect to the page
        masterProcessor.processResultValue(pageName);
        return;
    }
    // Otherwise, a component within a page. Components are transformed to implement RenderCommand, but if we just
    // pass the component itself to the master processor, we'll get in a loop, so we instead
    // pass the ComponentPageElement (which implements RenderCommand as well).
    Page page = cache.get(pageName);
    String nestedId = resources.getNestedId();
    RenderCommand command = page.getComponentElementByNestedId(nestedId);
    masterProcessor.processResultValue(command);
}
Also used : RenderCommand(org.apache.tapestry5.runtime.RenderCommand) Page(org.apache.tapestry5.internal.structure.Page) ComponentResources(org.apache.tapestry5.ComponentResources)

Example 3 with RenderCommand

use of org.apache.tapestry5.runtime.RenderCommand in project tapestry-5 by apache.

the class RenderQueueImplTest method run_commands.

@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);
        }
    };
    Logger logger = mockLogger();
    MarkupWriter writer = mockMarkupWriter();
    RenderQueueImpl queue = new RenderQueueImpl(logger);
    // There's only one check for trace enabled now.
    expect(logger.isTraceEnabled(TapestryMarkers.RENDER_COMMANDS)).andReturn(false);
    expect(logger.isDebugEnabled()).andReturn(true);
    logger.debug(eq(TapestryMarkers.RENDER_COMMANDS), isA(String.class));
    command2.render(writer, queue);
    replay();
    queue.push(command1);
    queue.run(writer);
    verify();
}
Also used : RenderCommand(org.apache.tapestry5.runtime.RenderCommand) RenderQueue(org.apache.tapestry5.runtime.RenderQueue) Logger(org.slf4j.Logger) MarkupWriter(org.apache.tapestry5.MarkupWriter) Test(org.testng.annotations.Test)

Example 4 with RenderCommand

use of org.apache.tapestry5.runtime.RenderCommand in project tapestry-5 by apache.

the class RenderQueueImplTest method command_failed.

@Test
public void command_failed() {
    ComponentResources foo = mockInternalComponentResources();
    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;
        }

        @Override
        public String toString() {
            return "FailedCommand";
        }
    };
    Logger logger = mockLogger();
    MarkupWriter writer = mockMarkupWriter();
    expect(logger.isTraceEnabled(TapestryMarkers.RENDER_COMMANDS)).andReturn(false);
    expect(logger.isDebugEnabled()).andReturn(true);
    logger.error("Render queue error in FailedCommand: Oops.", t);
    replay();
    RenderQueueImpl queue = new RenderQueueImpl(logger);
    queue.startComponent(foo);
    queue.startComponent(bar);
    queue.endComponent();
    queue.startComponent(baz);
    queue.push(rc);
    try {
        queue.run(writer);
        unreachable();
    } catch (RenderQueueException ex) {
        assertSame(ex.getCause(), t);
        assertArraysEqual(ex.getActiveComponents(), new Object[] { foo, baz });
    }
    verify();
}
Also used : RenderCommand(org.apache.tapestry5.runtime.RenderCommand) RenderQueue(org.apache.tapestry5.runtime.RenderQueue) Logger(org.slf4j.Logger) MarkupWriter(org.apache.tapestry5.MarkupWriter) ComponentResources(org.apache.tapestry5.ComponentResources) Test(org.testng.annotations.Test)

Example 5 with RenderCommand

use of org.apache.tapestry5.runtime.RenderCommand in project tapestry-5 by apache.

the class AjaxResponseRendererImpl method addRender.

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;
}
Also used : RenderCommand(org.apache.tapestry5.runtime.RenderCommand)

Aggregations

RenderCommand (org.apache.tapestry5.runtime.RenderCommand)18 MarkupWriter (org.apache.tapestry5.MarkupWriter)13 RenderQueue (org.apache.tapestry5.runtime.RenderQueue)13 Test (org.testng.annotations.Test)7 ComponentResources (org.apache.tapestry5.ComponentResources)3 TypeCoercer (org.apache.tapestry5.commons.services.TypeCoercer)3 Binding (org.apache.tapestry5.Binding)2 Block (org.apache.tapestry5.Block)2 Renderable (org.apache.tapestry5.Renderable)2 Element (org.apache.tapestry5.dom.Element)2 Logger (org.slf4j.Logger)2 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Calendar (java.util.Calendar)1 Collection (java.util.Collection)1 Date (java.util.Date)1 List (java.util.List)1 Map (java.util.Map)1 Pattern (java.util.regex.Pattern)1 Asset (org.apache.tapestry5.Asset)1