I thought I'd start another thread since my last thread got off topic
without answering my initial question.

I would like to write a component that takes a RenderCommand parameter (or
a Block parameter) and uses tapestry's template engine to get a html string
on the serverside. I do not want the html to be rendered to the response
output stream. I would instead like to use this html string to construct a
JSONObject.

I assume that tapestry must already be doing this somewhere in
MultiZoneUpdateEventResultProcessor which generates a JSONObject containing
all of the html strings to update on the client. I find the code hard to
follow and I'm hoping that someone can give me a snippit of code which will
take a RenderCommand and generate a html string.

This is my current attempt but I can't get it to work:

public class TmlToString {
        @Parameter
        @Property
        private RenderCommand renderMe;

        @BeginRender
        public void beginRender() {
                MarkupWriter writer = new MarkupWriterImpl();

                Logger logger = LoggerFactory.getLogger(TmlToString.class);
                RenderQueue renderQueue = new RenderQueueImpl(logger);

                Element element = writer.element("div");
                renderMe.render(writer, renderQueue);
                writer.end();

                System.out.println("childMarkup: " +
element.getChildMarkup()); // this is an empty string
                System.out.println("toString: " + element.toString()); //
prints <div></div>
        }
}


Cheers,
Lance.

Reply via email to