Re: JSON return from an event

2008-10-28 Thread Thiago H. de Paula Figueiredo

Em Tue, 28 Oct 2008 16:56:28 -0300, Ben Gidley <[EMAIL PROTECTED]> escreveu:


I should have been clearer - this is from an AJAX request.
What I have done is implement a JSON client inside a flex app that then
calls the event URL directly. Is there some magic in the URL that tells
tapestry it is an AJAX request?
Looking at the autocompleter there doesn't seem to be any.


Yes, but it is elsewhere. It's in RequestImpl.
Tapestry considers an AJAX requests when it's X-Requested-With header is  
set to XMLHttpRequest. ;)


--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JSON return from an event

2008-10-28 Thread Ben Gidley
I should have been clearer - this is from an AJAX request.
What I have done is implement a JSON client inside a flex app that then
calls the event URL directly. Is there some magic in the URL that tells
tapestry it is an AJAX request?

Looking at the autocompleter there doesn't seem to be any.

Thanks

Ben

On Mon, Oct 27, 2008 at 3:21 PM, Howard Lewis Ship <[EMAIL PROTECTED]> wrote:

> The JSON response is only recognized for Ajax requests; Tapestry
> differentiates between traditional requests and Ajax requests when
> handling the return value from an event handler method.
>
> When you use the zone parameter of an action link, Tapestry adds
> JavaScript to observe the click event on the client side, and to send
> an Ajax request to the server, and then update the zone's content
> based on the reply.
>
> If you want to do other kinds of Ajax updates, you need to write your
> own JavaScript code to observe the click event, send the Ajax request
> and interpret the response.
>
> On Sat, Oct 25, 2008 at 9:41 AM, Ben Gidley <[EMAIL PROTECTED]> wrote:
> > Hi,
> > I read the page on AJAX on the website and it implies I can return a
> > JSONObject directly from an event (if it is called via ajax).
> >
> > However when I implemented this - I got an error saying it didn't know
> what
> > to do with a JSON object. It does work if you encode the JSON response
> via a
> > TextStreamResponse.
> >
> > Is this a bug? - Or am a I missing something?
> >
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator Apache Tapestry and Apache HiveMind
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: JSON return from an event

2008-10-27 Thread Howard Lewis Ship
The JSON response is only recognized for Ajax requests; Tapestry
differentiates between traditional requests and Ajax requests when
handling the return value from an event handler method.

When you use the zone parameter of an action link, Tapestry adds
JavaScript to observe the click event on the client side, and to send
an Ajax request to the server, and then update the zone's content
based on the reply.

If you want to do other kinds of Ajax updates, you need to write your
own JavaScript code to observe the click event, send the Ajax request
and interpret the response.

On Sat, Oct 25, 2008 at 9:41 AM, Ben Gidley <[EMAIL PROTECTED]> wrote:
> Hi,
> I read the page on AJAX on the website and it implies I can return a
> JSONObject directly from an event (if it is called via ajax).
>
> However when I implemented this - I got an error saying it didn't know what
> to do with a JSON object. It does work if you encode the JSON response via a
> TextStreamResponse.
>
> Is this a bug? - Or am a I missing something?
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



JSON return from an event

2008-10-25 Thread Ben Gidley
Hi,
I read the page on AJAX on the website and it implies I can return a
JSONObject directly from an event (if it is called via ajax).

However when I implemented this - I got an error saying it didn't know what
to do with a JSON object. It does work if you encode the JSON response via a
TextStreamResponse.

Is this a bug? - Or am a I missing something?