Hi Lance,
I also tried this. But there is some problem. I had to handle the json
in this getMarkup method. Otherwise the json returned in my event
handler is not rendered.
Object onEventXXX()
{
JSONObject result=new JSONObject();
....
result.put("html",getMarkup(myblock) );
return result;
}
I can see the markup is generated correctly but the result received at
client is just empty. If I put needed content in the reply json object
in renderMarkup of the PartialMarkupRendererFilter, the client can
receive the good response. My guess is that the response is terminated
in getMarkup() so the returned json in the event handler is not rendered.
δΊ 2012/6/11 17:38, Lance Java ει:
Try this out (untested). If it works, I'll add it to the wiki page
public class AjaxRenderCommandMarkupRenderer {
private final PageRenderQueue pageRenderQueue;
private final AjaxFormUpdateController ajaxFormUpdateController;
private final AjaxPartialResponseRenderer partialRenderer;
// constructor
public String getMarkup(RenderCommand renderCommand) {
final StringBuilder builder = new StringBuiler();
pageRenderQueue.addPartialMarkupRendererFilter(new
PartialMarkupRendererFilter() {
public void renderMarkup(MarkupWriter writer, JSONObject reply,
PartialMarkupRenderer renderer)
{
Element root = writer.element("ajax-partial");
ajaxFormUpdateController.setupBeforePartialZoneRender(writer);
renderer.renderMarkup(writer, reply);
ajaxFormUpdateController.cleanupAfterPartialZoneRender();
writer.end();
builder.append(root.getChildMarkup().trim());
root.remove();
}
});
pageRenderQueue.addPartialRenderer(value);
partialRenderer.renderPartialPageMarkup();
return builder.toString();
}
}
--
View this message in context:
http://tapestry.1045711.n5.nabble.com/Howto-render-a-block-and-put-it-into-a-JSON-reply-tp5486823p5713760.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
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