You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by EveningSun <wo...@gmail.com> on 2009/12/22 09:10:07 UTC

JSON in Tapestry

Hi, I'm new to tapestry, now I want to create a page which could handle ajax
request and return JSON response. But I can't get it work. Here is what I
did:

First I have a page which extends BasePage and implement IJSONRender:
public abstract class JsonPage extends BasePage implements IJSONRender {
    public void renderComponent(IJSONWriter writer, IRequestCycle cycle) {
        System.out.println("RenderJSON!!");

        writer.array().put("some data");
    }
}

Then I have Home.page:
<page-specification class=".....JsonPage">
</page-specification>

Then I have Home.html:
<html jwcid="@Shell" title="Test">
<body jwcid="@Body">

<script>
    dojo.require("tapestry.event");

    dojo.event.connect(tapestry, "loadJson", function(type, data, http,
kwArgs){
        alert("load json!");
	alert("data:" + data);
	for (var e in data) {
		alert(e + ":" + data[e]);
	}
    });

    tapestry.bind("http://127.0.0.1:8080/war/app", {}, true);
</script>
</body>
</html>

The client side will show a message box said "load json!", but the json data
that client retrieved is always an empty object. Also, the server console
does not print "RenderJSON!!", which means that the renderComponent of my
TestPage was never called. I don't know what to do. Could somebody help me
out? Thank you very much!!
-- 
View this message in context: http://old.nabble.com/JSON-in-Tapestry-tp26885074p26885074.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: JSON in Tapestry

Posted by cleverpig <gr...@gmail.com>.
anywhere has code example for that?

On Wed, Dec 23, 2009 at 1:23 AM, Howard Lewis Ship <hl...@gmail.com> wrote:
> ... and all of this is easier in Tapestry 5, by design.
>
> On Tue, Dec 22, 2009 at 5:06 AM, Andreas Andreou <an...@di.uoa.gr> wrote:
>> I'm not sure if IJSONRender will work with pages, but i know it works with
>> components.
>>
>> The trick is then to generate a url that will rerender that component... similar
>> to a directlink url that defines the updateComponents parameter accordingly
>>
>> On Tue, Dec 22, 2009 at 10:35, EveningSun <wo...@gmail.com> wrote:
>>>
>>> I'm using Tapestry 4.1.6 by the way.
>>> --
>>> View this message in context: http://old.nabble.com/JSON-in-Tapestry-tp26885074p26885256.html
>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>>
>>
>> --
>> Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
>> Tapestry / Tacos developer
>> Open Source / JEE Consulting
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator of Apache Tapestry
>
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!
>
> (971) 678-5210
> http://howardlewisship.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
cleverpig(Dan)
Location: Beijing
Address: Room 4018,No.A2 South Avenue Fuxingmen Beijing,P.R.China
Zipcode: 100031
MSN: great_liudan@hotmail.com
QQ: 149291732
Skype: cleverpigatmatrix
Facebook ID:cleverpig
Blog: www.cleverpig.name
Tags: del.icio.us/cleverpig
Twitter: twitter.com/cleverpig
新浪微博: t.sina.com.cn/cleverpig
Organization: www.beijing-open-party.org
Organ@Facebook: http://www.facebook.com/group.php?gid=8159558294

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: JSON in Tapestry

Posted by Howard Lewis Ship <hl...@gmail.com>.
... and all of this is easier in Tapestry 5, by design.

On Tue, Dec 22, 2009 at 5:06 AM, Andreas Andreou <an...@di.uoa.gr> wrote:
> I'm not sure if IJSONRender will work with pages, but i know it works with
> components.
>
> The trick is then to generate a url that will rerender that component... similar
> to a directlink url that defines the updateComponents parameter accordingly
>
> On Tue, Dec 22, 2009 at 10:35, EveningSun <wo...@gmail.com> wrote:
>>
>> I'm using Tapestry 4.1.6 by the way.
>> --
>> View this message in context: http://old.nabble.com/JSON-in-Tapestry-tp26885074p26885256.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
>
> --
> Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
> Tapestry / Tacos developer
> Open Source / JEE Consulting
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: JSON in Tapestry

Posted by Andreas Andreou <an...@di.uoa.gr>.
I'm not sure if IJSONRender will work with pages, but i know it works with
components.

The trick is then to generate a url that will rerender that component... similar
to a directlink url that defines the updateComponents parameter accordingly

On Tue, Dec 22, 2009 at 10:35, EveningSun <wo...@gmail.com> wrote:
>
> I'm using Tapestry 4.1.6 by the way.
> --
> View this message in context: http://old.nabble.com/JSON-in-Tapestry-tp26885074p26885256.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: JSON in Tapestry

Posted by EveningSun <wo...@gmail.com>.
I'm using Tapestry 4.1.6 by the way.
-- 
View this message in context: http://old.nabble.com/JSON-in-Tapestry-tp26885074p26885256.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org