Thanks. I tried this and it works. One limitation is that, all the content in the block must be enclosed in a single html element. If the block is like this:
<t:block id='renderme'>
<t:loop ...>
<tr>...</tr>
</t:loop
</t:block>

The result only renders one tr element. I have to enclose the loop in a div to get all the rows rendered. Don't know why though. Here is my code(a little different):

public String renderMarkup(Block block)
{
RenderCommand renderCommand=typeCoercer.coerce(block, RenderCommand.class);
MarkupWriter markupWriter = new MarkupWriterImpl();
environment.push(Heartbeat.class, new HeartbeatImpl());
RenderQueueImpl renderQueue = new RenderQueueImpl(logger);
renderQueue.push(renderCommand);
renderQueue.run(markupWriter);
environment.pop(Heartbeat.class);
System.out.println("markup="+markupWriter.toString());
return markupWriter.toString().replaceAll("^\\n+","").replaceAll("\\n+$", "");
}

于 2012/2/16 22:00, dh ning 写道:
Hi,

To render block as html markup, I did like this:

public String renderMarkup(RenderCommand renderCommand) {
         MarkupWriter markupWriter = new MarkupWriterImpl();

         // validation track
         ValidationDecorator decorator = new
DefaultValidationDecorator(environment,
assetSource.getExpandedAsset("${tapestry.spacer-image}"), markupWriter);
         environment.push(ValidationDecorator.class, decorator);
         RenderQueueImpl renderQueue = new RenderQueueImpl(logger);
         renderQueue.push(renderCommand);
         renderQueue.run(markupWriter);

         environment.pop(ValidationDecorator.class);
         return markupWriter.toString().replaceAll("^\\n+",
"").replaceAll("\\n+$", "");
     }

and call renderMarkup((RenderCommand )block).

Not sure whether it is better than yours, hope it helps.

2012/2/16 Christian Riedel <cr.ml...@googlemail.com>

Hi there,

I'm trying to improve the tapestry5-jquery DataTable component, which is
able to respond paged results in JSON. Unfortunately the component is a bit
limited in terms of what can be returned. I want to add support for the
Grid-style p:propertyCell block-parameter-notation.
I'm looking for the most elegant way to do it. Currently I'm trying it
with faked zone updates (ajaxResponseRenderer.addRender) and a filter
(ajaxResponseRenderer.addFilter) that should modify the JSON reply object.
It feels very clumsy and I thought if someone on the list could point me to
a more elegant solution.

More Abstract:
We've got
- an Ajax callback: void onData() { ... }
- PropertyOverrides, having block parameters
- a working data source that is able to fetch data by the current page

We need
- loop over all rows of the current page and
- render each cell's content or its override into a row-json-array and
- put each row-json-array into a data json-array

Is there another way than using ajaxResponseRenderer.addRender / addFilter?

Cheers
Christian
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to