Hi Thiago,

Thanks for your help. I have already gotten it working.

I have tested my event handler in two ways.

1. Just typed the appropriate URL to browser address line. Of course, this is 
not an AJAX request. It works when using a MarkupWriter but produces an 
exception when returning a block.

2. Debugged the real page on client side using Firebug and Wireshark. The page 
fires the AJAX request via jQuery.ajax() function. I had to make some stupid 
mistake two days ago as it already works today. Beside others, I overlooked 
that in case of returning a Tapestry block, the resulting HTML is wrapped into 
a JSON object, in contrast to using a MarkupWriter (just like in Autocomplete).

Regards,
Jarda



> On Jun2, 2016, at 13:59, Thiago H de Paula Figueiredo <thiag...@gmail.com> 
> wrote:
> 
> 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
> 


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

Reply via email to