You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Denis Burlaka <de...@gmail.com> on 2007/05/23 10:09:41 UTC

T4.1.2 and JSON

Hi, All

I need to implement the next logic. The form component sends AJAX JSON
request to the server, server makes the list of items and returns it back as
JSON object, on the client side I need to populate the table from that list.
I think I must implement my own component derived from AbstractComponent and
override renderComponent(IMarkupWriter writer, IRequestCycle cycle) method
and prepare JSON object in it, but how to pass it back to the client and how
to process it on the client side?
Any advice or examples welcome.

Thanks.

Re: T4.1.2 and JSON

Posted by Jesse Kuhnert <jk...@gmail.com>.
On the server side all you need to do is implement this interface in your
page or component:

http://tapestry.apache.org/tapestry4.1/apidocs/org/apache/tapestry/IJSONRender.html

There is only a dummy stub function definition for JSON responses on the
tapestry client side, so you must re-define what that function does in order
to do something with the data returned:

tapestry.loadJson=function(type, data, http, kwArgs){}

The data parameter should be your json eval'd data structure.

On 5/23/07, Denis Burlaka <de...@gmail.com> wrote:
>
> Hi, All
>
> I need to implement the next logic. The form component sends AJAX JSON
> request to the server, server makes the list of items and returns it back
> as
> JSON object, on the client side I need to populate the table from that
> list.
> I think I must implement my own component derived from AbstractComponent
> and
> override renderComponent(IMarkupWriter writer, IRequestCycle cycle) method
> and prepare JSON object in it, but how to pass it back to the client and
> how
> to process it on the client side?
> Any advice or examples welcome.
>
> Thanks.
>



-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com