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

Reply via email to