I've also had a use-case like this - I wanted to use tapestry to
generate html based on a .tml, in response to an ajax request that I was
initiating from my own javascript, ie nothing to do with a zone.

We've had a few people on the list say they'd like to do this. Given
that tapestry is doing this internally in response on a zone request,
it'd be great if this were exposed so that you could render a block and
return the result yourself.



On Sat, 2011-02-26 at 11:23 -0600, Adam Zimowski wrote:
> That was my issue. I did not want to work with zones either, and as a
> result pounded my head against the wall. Using Tapestry features -
> zones and blocks - solves this problem (although not very intuitive).
> The tricky part is the Tapestry specific JavaScript which isn't
> readily documented.
> 
> On Sat, Feb 26, 2011 at 11:21 AM, Jonathan Barker
> <jonathan.theit...@gmail.com> wrote:
> > Unless I'm missing something (which is possible), in both cases the
> > complexity comes because you are trying to NOT use the features of Tapestry.
> >  Both of you want to bypass the tools Tapestry gives you.
> >
> > Use an EventLink and use a context and a zone.
> >
> > As for an arbitrary div...  you can update any Zone you want.
> >
> > Zones take some getting used to, but it feels like you're fighting the
> > framework. Using Zones and components like ProgressiveDisplay, I've created
> > stuff that also degrades nicely when there's no javascript available, which
> > is something else to consider.
> >
> > Did I miss something?
> >
> > Regards,
> > Jonathan
> >
> > On Sat, Feb 26, 2011 at 12:01 PM, Adam Zimowski <zimowsk...@gmail.com>wrote:
> >
> >> Heh.. this is funny, but it sounds like the issue I just described in
> >> my "Grid with multiple forms" thread. Anyway, to call a Tapestry event
> >> from a JavaScript you probably want this in your javascript:
> >>
> >> function yourJavaScriptMethod(yourParameterIfYouHaveOne) {
> >>    var url = '${tapestryEvent}' + '/' + yourParameterIfYouHaveOne;
> >>    var zm = Tapestry.findZoneManagerForZone("yourZone");
> >>    zm.updateFromURL(url);
> >> }
> >>
> >> And this in your page class:
> >>
> >> Object onTapestryEvent(String parameterIfYouNeedIt) {
> >>  return yourBlock;
> >> }
> >>
> >> public String getAddToCartUrl() {
> >>  return resources.createEventLink("tapestryEvent").toURI();
> >> }
> >>
> >> Adam
> >>
> >> On Sat, Feb 26, 2011 at 10:52 AM, Tom van Dijk <t...@tvandijk.nl> wrote:
> >> > Hi,
> >> >
> >> > Well, it is an AJAX request. The X-Requested-With header is properly set,
> >> > isXHR() will return true. I'm executing it in Javascript, just a normal
> >> > call. It's supposed to return a form that I can then display in any DIV
> >> that
> >> > I want, and I don't want to use zones here. So I would think I should add
> >> a
> >> > method in my Page class, "getStuff" or something like that. And I
> >> basically
> >> > want to call that method, which returns a Block, from Javascript and get
> >> the
> >> > actual rendered HTML to put in any DIV of my choice.
> >> >
> >> > How?
> >> >
> >> > Tom.
> >> >
> >> > Op 26-2-2011 16:35, Josh Canfield schreef:
> >> >>
> >> >> Hi Tom.
> >> >>
> >> >> You can definitely return a block as the result of an AJAX request. If
> >> >> it's
> >> >> not an AJAX request then you will get an error about not having a result
> >> >> processor.
> >> >>
> >> >> Make sure that the zone parameter is set on the link you are using to
> >> >> initiate the zone update, and that javascript is turned on. You can
> >> check
> >> >> the request for isXHR to make sure tapestry thinks you are doing an ajax
> >> >> request.
> >> >>
> >> >> Josh
> >> >> On Feb 26, 2011 5:52 AM, "Tom van Dijk"<t...@tvandijk.nl>  wrote:
> >> >>>
> >> >>> Hello,
> >> >>>
> >> >>> I want to do something that should be simple but appears to be complex.
> >> >>>
> >> >>> I want to render a Block and return the result. The context is a
> >> website
> >> >>> in which I want to use Javascript to fill a<div>. I don't want to use a
> >> >>> zone for this. What I did was make a<t:block>  in the .tml file. Now
> >> what
> >> >>
> >> >> I
> >> >>>
> >> >>> want to do is send an event to the page, and return the rendered block
> >> >>> using JSON. A bit like this:
> >> >>>
> >> >>> @Inject
> >> >>> private Block theBlock;
> >> >>>
> >> >>> Object onTheEvent() {
> >> >>> return theBlock;
> >> >>> }
> >> >>>
> >> >>> I figured out that this doesn't work, because BlockImpl is not handled.
> >> >>> Okay, I have to return a StreamResponse. What I would like is:
> >> >>>
> >> >>> @Inject
> >> >>> private final BlockRenderer renderer;
> >> >>>
> >> >>> Object onTheEvent() {
> >> >>> return new TextStreamResponse("text/html", renderer.render(theBlock));
> >> >>> }
> >> >>>
> >> >>> Obviously the BlockRenderer service does not exist, but I would want it
> >> >>> to
> >> >>> exist. Or something similar.
> >> >>>
> >> >>> Who can help me out?
> >> >>>
> >> >>> Tom.
> >> >>>
> >> >>> ---------------------------------------------------------------------
> >> >>> 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
> >> >
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> >> For additional commands, e-mail: users-h...@tapestry.apache.org
> >>
> >>
> >
> >
> > --
> > Jonathan Barker
> > ITStrategic
> >
> 
> ---------------------------------------------------------------------
> 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