If you only need to get HTML on the client and not on the server-side, then you may just use Tapestry's built-in logic for handling AJAX requests.
On the server side create eventLink: Link link = resources.createEventLink(eventType, contextValues); return link.toAbsoluteURI(); Pass this link to client side during rendering and when needed do the AJAX calls using, say, jQuery.ajax. You may handle ajax request on the server side the same way I wrote in my example above -- return block from event handler or use ajaxResponseRenderer.addRender(). On the client-side response will be the same JSON and you may extract content from it. Note that in both cases it is possible to render multiple blocks by one request -- this is if you call ajaxResponseRenderer.addRender() multiple times. On Thu, Jun 6, 2013 at 1:12 AM, Muhammad Gelbana <m.gelb...@gmail.com>wrote: > Actually Lance's second approach is what I need to do. And yes it should be > very simple, I will only have to display regular html without controls at > all (Hopefully it will stay this way and I actually think it will) > > Regards > > > On Wed, Jun 5, 2013 at 8:00 PM, Dmitry Gusev <dmitry.gu...@gmail.com> > wrote: > > > The entry point is: > > > > String rawAddress = renderer.render(new RenderEvent( > > "internal/companyblocks", "companyAddress", company)); > > > > > > You tell here that onCompanyAddress method (or method with > > @Event("companyAddress")) should be invoked on the internal/companyblocks > > page > > class and if that method returns a Block - it will be rendered to a > string. > > company - is a parameter to that method that you may use to initialize > > rendering context for the block. > > You can also not return Block from the method by just addRenderer: > > > > ajaxResponseRenderer.addRender(addressBlockZone); > > > > And the addressBlockZone will be rendered to as string in this case. > > > > Resulting string will be serialized json object, so you can inspect its > > structure and take the content you want like: > > > > String htmlAddress = new > > JSONObject(rawAddress).getString("content"); > > > > > > On Wed, Jun 5, 2013 at 8:14 PM, Muhammad Gelbana <m.gelb...@gmail.com > > >wrote: > > > > > Honestly, I can't figure out anything from these 2 resources ! It all > > looks > > > so complicated to me. > > > > > > @Dmitry > > > What is the entry point of your code ? When an ajaxrequest is sent to > my > > > application, doesn't it reach your "CompanyBlocks" page ? Then when > does > > > all the other services begin working ?! > > > > > > @Lanve > > > And I thought Dimitry's code was complicated :D > > > Your code was even harder to look at, I also can't understand the entry > > > point and the flow of data starting when I receive an ajax request > till I > > > respond with a string representation of a component's template file. > > > > > > Thank you all for your help :) > > > > > > > > > On Thu, May 30, 2013 at 6:41 PM, Lance Java <lance.j...@googlemail.com > > > >wrote: > > > > > > > I'm not 100% sure what your implementation will be but I've done some > > > work > > > > in this area. > > > > > > > > Take a look at PDFLink.getFoAsString() where I convert a > RenderCommand > > > to a > > > > String of markup (XML in the example) > > > > > > > > http://tapestry-stitch.uklance.cloudbees.net/pdflinkdemo > > > > > > > > Also, take a look at this wiki entry > > > > > > > > > > > > > > > > > > http://wiki.apache.org/tapestry/Tapestry5HowToGetAnHTMLStringFromARenderCommandParameter > > > > > > > > Note that a Block can be type coerced to a RenderCommand > > > > > > > > > > > > > > > -- > > Dmitry Gusev > > > > AnjLab Team > > http://anjlab.com > > > -- Dmitry Gusev AnjLab Team http://anjlab.com