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.
}
}
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);
}
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();
}
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();
}
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;
}
Aggregations