On Thu, 02 Jun 2016 04:59:10 -0300, Jaroslav Ciml <jaroslav.c...@jpower8.cz> wrote:

Hi,

Hi!

I'm using Tapestry 5.3.

If you want to render a block or component or anything that can be coerced to a RenderCommand, Tapestry 5.4 has the PartialTemplateRenderer service:
http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/PartialTemplateRenderer.html.

Example:
https://github.com/apache/tapestry-5/blob/master/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/PartialTemplateRendererDemo.java

You can see and copy its sources from https://github.com/apache/tapestry-5/blob/master/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PartialTemplateRendererImpl.java.

In a Tapestry component, I'm trying to implement an event handler that creates responses to AJAX requests.

I know that I can call MarkupWriterFactory#newPartialMarkupWriter to get an instance of MarkupWriter and then generate the response using this MarkupWriter instance. The built-in mixin Autocomplete generates responses to AJAX requests in this way.

You really don't need to do it this way.

However, I wonder if there is a chance to create such response using a Tapestry block rather than generating the response "manually" via MarkupWriter.

Just return the block instance in your AJAX event handler method.

If I just return an instance of block from the event handler, an exception is thrown.

Weird. Tapestry does support block event handler return methods for AJAX requests (i.e. the ones in which Request.isXHR() returns true). How are you testing your event handler method?

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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

Reply via email to