You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Alexandru Dragomir <al...@gmail.com> on 2006/12/16 15:15:42 UTC

using json response

I'm working on a component that expects a json response (.. frankly , i'm
not sure anymore about this)

Is a dojo widget that i'm trying to convert into tapestry.

A valid response would be :

({title: "a new title"})

or even

dojo.debug("server gave a new title"); ({title: "a new title"})

The problem is that using the JSONWriter i get something like :

{"title" : "a new title"} -> the title is quoted and i think that is why i
get  an error saying  SyntaxError: invalid label

If i don't use JSON response , i use XML , which is not good either.

Any suggestion of what i'm doing wrong ?
Should i build a custom ResponseBuilder or Writer ?

thanks!
Alex

Re: using json response

Posted by Alexandru Dragomir <al...@gmail.com>.
>From what i've seen , the second option is the right one : i'm not returning
what the tree is expecting.
In the begining i thought it was json but now is clear that's , as you said
, javascript content.

I'll check the response builder to see if i can treat this somehow.


On 12/17/06, Jesse Kuhnert <jk...@gmail.com> wrote:
>
> I'd say that this is a bug in the tree controller. Tapestry "should
> not" be sending back any JSON data enclosed with "()".
>
> This represents a browser "quirck" and should be handled in the
> appropriate place - the browser. I'd bring it up with dojo, probably
> by filing a bug in http://trac.dojotoolkit.org .
>
> A mimetype of text/javascript means you are expecting javascript
> content such as "function foo(){} " - json mimetype is for object
> structures that need to be evaluated in line. Either the tree is
> incorrectly using javascript mimetype when it should be using json or
> you aren't returning what the tree is expecting.
>
> On 12/17/06, Alexandru Dragomir <al...@gmail.com> wrote:
> > Some good news.
> > In TreeLoadingControllerV3.js , runRpc  , the  mimetype is set as
> > "text/javascript".
> >
> > In method doLoad from BrowserIO.js :
> >  - if mimetype is "text/javascript" the method dj_eval(http.responseText
> );
> > is called
> >  - if mimetype is "*/json" the method
> dj_eval("("+http.responseText+")"); is
> > called
> >
> > So that's why the brackets are not added and must be set from the
> server..
> >
> > A suggestion of how should i go on ?
> > Should i build a custom ReponseBuilder that treats the text/javascript
> > mimetype ? Would be beter to be in the framework.. ?
> >
> > Alex
> >
> >
> >
> >
> >
> > On 12/17/06, Alexandru Dragomir <al...@gmail.com> wrote:
> > >
> > > I've been looking into TreeRpcControllerV3.js and TreeEditor.js for
> the
> > > place where the response is handled , but i haven't got any result
> beside a
> > > headache.. :)
> > >
> > > Any suggestion is welcome !
> > >
> > > Alex
> > >
> > >
> > > On 12/17/06, Alexandru Dragomir <al...@gmail.com> wrote:
> > > >
> > > > I tried it but is still not working.
> > > >
> > > > But i found something else. I manage to hook the JSONWriterImpl and
> send
> > > > whatever plain text i want to the client.
> > > > When i send the string : ({title: 'a new title'}) is working.
> > > > When i send the string : {title: 'a new title'} is not  working.
> > > >
> > > > So the conclusion is that  the brackets  "()" must be sent.
> > > >
> > > > Is this the way the widget should work ?
> > > > Maybe i should put this question to dojo list ?
> > > >
> > > > thanks!
> > > > Alex
> > > >
> > > > On 12/16/06, Jesse Kuhnert < jkuhnert@gmail.com> wrote:
> > > > >
> > > > > Maybe the tree widget is expecting a json array vs object being
> > > > > returned...Ie ["title","a new title"]. You can do that easily by
> doing
> > > > > this instead:
> > > > >
> > > > > JSONArray arr = writer.array();
> > > > > arr.put ("title");
> > > > > arr.put("a new title");
> > > > >
> > > > >
> > > > >
> > > > > On 12/16/06, Jesse Kuhnert <jkuhnert@gmail.com > wrote:
> > > > > > Yes, that should be fine. It is a perfectly valid JSON response.
> > > > > There
> > > > > > aren't too many ways to vary it.
> > > > > >
> > > > > > On 12/16/06, Alexandru Dragomir <alex.dragomir@gmail.com >
> wrote:
> > > > > > > ok, then i might be doing something else wrong..
> > > > > > > Is the tree widget.
> > > > > > > And now i'm at editing a node label phase.
> > > > > > > I edit , press enter , and the response received is  {"title"
> : "a
> > > > > new
> > > > > > > title"} without other brackets.
> > > > > > >
> > > > > > > The render method is
> > > > > > > public void renderComponent(IJSONWriter writer, IRequestCycle
> > > > > cycle)
> > > > > > >     {
> > > > > > >
> > > > > > >         JSONObject json = writer.object();
> > > > > > >         json.put("title", "a new title");
> > > > > > >      }
> > > > > > >
> > > > > > > Alex
> > > > > > >
> > > > > > >
> > > > > > > On 12/16/06, Jesse Kuhnert < jkuhnert@gmail.com> wrote:
> > > > > > > >
> > > > > > > > Quoting/not quoting a response should have nothing to do
> with it
> > > > > being
> > > > > > > > valid JSON. Nor should a response contain the surrounding
> "("
> > > > > content
> > > > > > > > ")".
> > > > > > > >
> > > > > > > > I'd be interested in knowing which dojo widget this is but
> if
> > > > > it's
> > > > > > > > using dojo.io as the transport layer it should be adding in
> the
> > > > > "("
> > > > > > > > for you.
> > > > > > > >
> > > > > > > > On 12/16/06, Alexandru Dragomir <alex.dragomir@gmail.com >
> > > > > wrote:
> > > > > > > > > I'm working on a component that expects a json response
> (..
> > > > > frankly ,
> > > > > > > > i'm
> > > > > > > > > not sure anymore about this)
> > > > > > > > >
> > > > > > > > > Is a dojo widget that i'm trying to convert into tapestry.
> > > > > > > > >
> > > > > > > > > A valid response would be :
> > > > > > > > >
> > > > > > > > > ({title: "a new title"})
> > > > > > > > >
> > > > > > > > > or even
> > > > > > > > >
> > > > > > > > > dojo.debug("server gave a new title"); ({title: "a new
> > > > > title"})
> > > > > > > > >
> > > > > > > > > The problem is that using the JSONWriter i get something
> like
> > > > > :
> > > > > > > > >
> > > > > > > > > {"title" : "a new title"} -> the title is quoted and i
> think
> > > > > that is why
> > > > > > > > i
> > > > > > > > > get  an error saying  SyntaxError: invalid label
> > > > > > > > >
> > > > > > > > > If i don't use JSON response , i use XML , which is not
> good
> > > > > either.
> > > > > > > > >
> > > > > > > > > Any suggestion of what i'm doing wrong ?
> > > > > > > > > Should i build a custom ResponseBuilder or Writer ?
> > > > > > > > >
> > > > > > > > > thanks!
> > > > > > > > > Alex
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Jesse Kuhnert
> > > > > > > > Tapestry/Dojo team member/developer
> > > > > > > >
> > > > > > > > Open source based consulting work centered around
> > > > > > > > dojo/tapestry/tacos/hivemind.
> http://blog.opencomponentry.com
> > > > > > > >
> > > > > > > >
> > > > >
> ---------------------------------------------------------------------
> > > > > > > > To unsubscribe, e-mail:
> users-unsubscribe@tapestry.apache.org
> > > > > > > > For additional commands, e-mail:
> users-help@tapestry.apache.org
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Jesse Kuhnert
> > > > > > Tapestry/Dojo team member/developer
> > > > > >
> > > > > > Open source based consulting work centered around
> > > > > > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Jesse Kuhnert
> > > > > Tapestry/Dojo team member/developer
> > > > >
> > > > > Open source based consulting work centered around
> > > > > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> > > > >
> > > > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > > >
> > > > >
> > > >
> > >
> >
> >
>
>
> --
> Jesse Kuhnert
> Tapestry/Dojo team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: using json response

Posted by Alexandru Dragomir <al...@gmail.com>.
True.
I overwritten the runRpc from the controller changing to "text/json" and it
worked smoothly !
Hope i'm not going into other issue doing this :)
 thanks !

var controller = dojo.widget.createWidget("TreeRpcControllerV3",{editor:
editorul.widgetId,widgetId: "controller",RpcUrl:"${url}",
                    runRpc: function(kw) {
                        var _this = this;
                        var deferred = new dojo.Deferred();
                        dojo.io.bind({
                            url: kw.url,
                            handle: this.getDeferredBindHandler(deferred),
                            mimetype: "text/json",
                            preventCache: this.preventCache,
                            sync: kw.sync,
                            content: { data: dojo.json.serialize(kw.params)
}
                        });
                        return deferred;
                    }});

On 12/17/06, Jesse Kuhnert <jk...@gmail.com> wrote:
>
> Well be careful ...I'm not saying for sure that I know what is the
> right approach in this particular instance, but I do know that I don't
> like that tree widget at all. It may very well be a bad design
> decision on the widget authors part, so just be careful jumping
> through too many hoops if you don't have to.
>
> Overriding an existing javascript object function (esp a widget
> function) is very easy to do. something like
> dojo.lang.extend(name.of.Object,
> function:myOverrideFunction(){doYourStuff}) would probably be the
> easiest way to fix a faulty function.
>
> On 12/17/06, Alexandru Dragomir <al...@gmail.com> wrote:
> > I think it can be handled very well with what is existing already in
> > framework.
> > I just took the wrong approach at the begining thinking that is json
> > response.
> > I'll post back after some time.
> >
> > thanks.
> > Alex
> >
> > On 12/17/06, andyhot <an...@di.uoa.gr> wrote:
> > >
> > > Jesse Kuhnert wrote:
> > > > I'd say that this is a bug in the tree controller. Tapestry "should
> > > > not" be sending back any JSON data enclosed with "()".
> > > +1
> > >
> > >
> > > > Either the tree is
> > > > incorrectly using javascript mimetype when it should be using json
> or
> > > > you aren't returning what the tree is expecting.
> > >
> > > Or, there's simply a need for a new JavascriptResponseBuilder
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
> >
>
>
> --
> Jesse Kuhnert
> Tapestry/Dojo team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: using json response

Posted by Jesse Kuhnert <jk...@gmail.com>.
Well be careful ...I'm not saying for sure that I know what is the
right approach in this particular instance, but I do know that I don't
like that tree widget at all. It may very well be a bad design
decision on the widget authors part, so just be careful jumping
through too many hoops if you don't have to.

Overriding an existing javascript object function (esp a widget
function) is very easy to do. something like
dojo.lang.extend(name.of.Object,
function:myOverrideFunction(){doYourStuff}) would probably be the
easiest way to fix a faulty function.

On 12/17/06, Alexandru Dragomir <al...@gmail.com> wrote:
> I think it can be handled very well with what is existing already in
> framework.
> I just took the wrong approach at the begining thinking that is json
> response.
> I'll post back after some time.
>
> thanks.
> Alex
>
> On 12/17/06, andyhot <an...@di.uoa.gr> wrote:
> >
> > Jesse Kuhnert wrote:
> > > I'd say that this is a bug in the tree controller. Tapestry "should
> > > not" be sending back any JSON data enclosed with "()".
> > +1
> >
> >
> > > Either the tree is
> > > incorrectly using javascript mimetype when it should be using json or
> > > you aren't returning what the tree is expecting.
> >
> > Or, there's simply a need for a new JavascriptResponseBuilder
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

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

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


Re: using json response

Posted by Alexandru Dragomir <al...@gmail.com>.
I think it can be handled very well with what is existing already in
framework.
I just took the wrong approach at the begining thinking that is json
response.
I'll post back after some time.

thanks.
Alex

On 12/17/06, andyhot <an...@di.uoa.gr> wrote:
>
> Jesse Kuhnert wrote:
> > I'd say that this is a bug in the tree controller. Tapestry "should
> > not" be sending back any JSON data enclosed with "()".
> +1
>
>
> > Either the tree is
> > incorrectly using javascript mimetype when it should be using json or
> > you aren't returning what the tree is expecting.
>
> Or, there's simply a need for a new JavascriptResponseBuilder
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: using json response

Posted by andyhot <an...@di.uoa.gr>.
Jesse Kuhnert wrote:
> I'd say that this is a bug in the tree controller. Tapestry "should
> not" be sending back any JSON data enclosed with "()".
+1


> Either the tree is
> incorrectly using javascript mimetype when it should be using json or
> you aren't returning what the tree is expecting.

Or, there's simply a need for a new JavascriptResponseBuilder


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


Re: using json response

Posted by Jesse Kuhnert <jk...@gmail.com>.
I'd say that this is a bug in the tree controller. Tapestry "should
not" be sending back any JSON data enclosed with "()".

This represents a browser "quirck" and should be handled in the
appropriate place - the browser. I'd bring it up with dojo, probably
by filing a bug in http://trac.dojotoolkit.org .

A mimetype of text/javascript means you are expecting javascript
content such as "function foo(){} " - json mimetype is for object
structures that need to be evaluated in line. Either the tree is
incorrectly using javascript mimetype when it should be using json or
you aren't returning what the tree is expecting.

On 12/17/06, Alexandru Dragomir <al...@gmail.com> wrote:
> Some good news.
> In TreeLoadingControllerV3.js , runRpc  , the  mimetype is set as
> "text/javascript".
>
> In method doLoad from BrowserIO.js :
>  - if mimetype is "text/javascript" the method dj_eval(http.responseText);
> is called
>  - if mimetype is "*/json" the method dj_eval("("+http.responseText+")"); is
> called
>
> So that's why the brackets are not added and must be set from the server..
>
> A suggestion of how should i go on ?
> Should i build a custom ReponseBuilder that treats the text/javascript
> mimetype ? Would be beter to be in the framework.. ?
>
> Alex
>
>
>
>
>
> On 12/17/06, Alexandru Dragomir <al...@gmail.com> wrote:
> >
> > I've been looking into TreeRpcControllerV3.js and TreeEditor.js for the
> > place where the response is handled , but i haven't got any result beside a
> > headache.. :)
> >
> > Any suggestion is welcome !
> >
> > Alex
> >
> >
> > On 12/17/06, Alexandru Dragomir <al...@gmail.com> wrote:
> > >
> > > I tried it but is still not working.
> > >
> > > But i found something else. I manage to hook the JSONWriterImpl and send
> > > whatever plain text i want to the client.
> > > When i send the string : ({title: 'a new title'}) is working.
> > > When i send the string : {title: 'a new title'} is not  working.
> > >
> > > So the conclusion is that  the brackets  "()" must be sent.
> > >
> > > Is this the way the widget should work ?
> > > Maybe i should put this question to dojo list ?
> > >
> > > thanks!
> > > Alex
> > >
> > > On 12/16/06, Jesse Kuhnert < jkuhnert@gmail.com> wrote:
> > > >
> > > > Maybe the tree widget is expecting a json array vs object being
> > > > returned...Ie ["title","a new title"]. You can do that easily by doing
> > > > this instead:
> > > >
> > > > JSONArray arr = writer.array();
> > > > arr.put ("title");
> > > > arr.put("a new title");
> > > >
> > > >
> > > >
> > > > On 12/16/06, Jesse Kuhnert <jkuhnert@gmail.com > wrote:
> > > > > Yes, that should be fine. It is a perfectly valid JSON response.
> > > > There
> > > > > aren't too many ways to vary it.
> > > > >
> > > > > On 12/16/06, Alexandru Dragomir <alex.dragomir@gmail.com > wrote:
> > > > > > ok, then i might be doing something else wrong..
> > > > > > Is the tree widget.
> > > > > > And now i'm at editing a node label phase.
> > > > > > I edit , press enter , and the response received is  {"title" : "a
> > > > new
> > > > > > title"} without other brackets.
> > > > > >
> > > > > > The render method is
> > > > > > public void renderComponent(IJSONWriter writer, IRequestCycle
> > > > cycle)
> > > > > >     {
> > > > > >
> > > > > >         JSONObject json = writer.object();
> > > > > >         json.put("title", "a new title");
> > > > > >      }
> > > > > >
> > > > > > Alex
> > > > > >
> > > > > >
> > > > > > On 12/16/06, Jesse Kuhnert < jkuhnert@gmail.com> wrote:
> > > > > > >
> > > > > > > Quoting/not quoting a response should have nothing to do with it
> > > > being
> > > > > > > valid JSON. Nor should a response contain the surrounding "("
> > > > content
> > > > > > > ")".
> > > > > > >
> > > > > > > I'd be interested in knowing which dojo widget this is but if
> > > > it's
> > > > > > > using dojo.io as the transport layer it should be adding in the
> > > > "("
> > > > > > > for you.
> > > > > > >
> > > > > > > On 12/16/06, Alexandru Dragomir <alex.dragomir@gmail.com >
> > > > wrote:
> > > > > > > > I'm working on a component that expects a json response (..
> > > > frankly ,
> > > > > > > i'm
> > > > > > > > not sure anymore about this)
> > > > > > > >
> > > > > > > > Is a dojo widget that i'm trying to convert into tapestry.
> > > > > > > >
> > > > > > > > A valid response would be :
> > > > > > > >
> > > > > > > > ({title: "a new title"})
> > > > > > > >
> > > > > > > > or even
> > > > > > > >
> > > > > > > > dojo.debug("server gave a new title"); ({title: "a new
> > > > title"})
> > > > > > > >
> > > > > > > > The problem is that using the JSONWriter i get something like
> > > > :
> > > > > > > >
> > > > > > > > {"title" : "a new title"} -> the title is quoted and i think
> > > > that is why
> > > > > > > i
> > > > > > > > get  an error saying  SyntaxError: invalid label
> > > > > > > >
> > > > > > > > If i don't use JSON response , i use XML , which is not good
> > > > either.
> > > > > > > >
> > > > > > > > Any suggestion of what i'm doing wrong ?
> > > > > > > > Should i build a custom ResponseBuilder or Writer ?
> > > > > > > >
> > > > > > > > thanks!
> > > > > > > > Alex
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Jesse Kuhnert
> > > > > > > Tapestry/Dojo team member/developer
> > > > > > >
> > > > > > > Open source based consulting work centered around
> > > > > > > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> > > > > > >
> > > > > > >
> > > > ---------------------------------------------------------------------
> > > > > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Jesse Kuhnert
> > > > > Tapestry/Dojo team member/developer
> > > > >
> > > > > Open source based consulting work centered around
> > > > > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> > > > >
> > > >
> > > >
> > > > --
> > > > Jesse Kuhnert
> > > > Tapestry/Dojo team member/developer
> > > >
> > > > Open source based consulting work centered around
> > > > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > >
> > > >
> > >
> >
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

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

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


Re: using json response

Posted by Alexandru Dragomir <al...@gmail.com>.
Some good news.
In TreeLoadingControllerV3.js , runRpc  , the  mimetype is set as
"text/javascript".

In method doLoad from BrowserIO.js :
 - if mimetype is "text/javascript" the method dj_eval(http.responseText);
is called
 - if mimetype is "*/json" the method dj_eval("("+http.responseText+")"); is
called

So that's why the brackets are not added and must be set from the server..

A suggestion of how should i go on ?
Should i build a custom ReponseBuilder that treats the text/javascript
mimetype ? Would be beter to be in the framework.. ?

Alex





On 12/17/06, Alexandru Dragomir <al...@gmail.com> wrote:
>
> I've been looking into TreeRpcControllerV3.js and TreeEditor.js for the
> place where the response is handled , but i haven't got any result beside a
> headache.. :)
>
> Any suggestion is welcome !
>
> Alex
>
>
> On 12/17/06, Alexandru Dragomir <al...@gmail.com> wrote:
> >
> > I tried it but is still not working.
> >
> > But i found something else. I manage to hook the JSONWriterImpl and send
> > whatever plain text i want to the client.
> > When i send the string : ({title: 'a new title'}) is working.
> > When i send the string : {title: 'a new title'} is not  working.
> >
> > So the conclusion is that  the brackets  "()" must be sent.
> >
> > Is this the way the widget should work ?
> > Maybe i should put this question to dojo list ?
> >
> > thanks!
> > Alex
> >
> > On 12/16/06, Jesse Kuhnert < jkuhnert@gmail.com> wrote:
> > >
> > > Maybe the tree widget is expecting a json array vs object being
> > > returned...Ie ["title","a new title"]. You can do that easily by doing
> > > this instead:
> > >
> > > JSONArray arr = writer.array();
> > > arr.put ("title");
> > > arr.put("a new title");
> > >
> > >
> > >
> > > On 12/16/06, Jesse Kuhnert <jkuhnert@gmail.com > wrote:
> > > > Yes, that should be fine. It is a perfectly valid JSON response.
> > > There
> > > > aren't too many ways to vary it.
> > > >
> > > > On 12/16/06, Alexandru Dragomir <alex.dragomir@gmail.com > wrote:
> > > > > ok, then i might be doing something else wrong..
> > > > > Is the tree widget.
> > > > > And now i'm at editing a node label phase.
> > > > > I edit , press enter , and the response received is  {"title" : "a
> > > new
> > > > > title"} without other brackets.
> > > > >
> > > > > The render method is
> > > > > public void renderComponent(IJSONWriter writer, IRequestCycle
> > > cycle)
> > > > >     {
> > > > >
> > > > >         JSONObject json = writer.object();
> > > > >         json.put("title", "a new title");
> > > > >      }
> > > > >
> > > > > Alex
> > > > >
> > > > >
> > > > > On 12/16/06, Jesse Kuhnert < jkuhnert@gmail.com> wrote:
> > > > > >
> > > > > > Quoting/not quoting a response should have nothing to do with it
> > > being
> > > > > > valid JSON. Nor should a response contain the surrounding "("
> > > content
> > > > > > ")".
> > > > > >
> > > > > > I'd be interested in knowing which dojo widget this is but if
> > > it's
> > > > > > using dojo.io as the transport layer it should be adding in the
> > > "("
> > > > > > for you.
> > > > > >
> > > > > > On 12/16/06, Alexandru Dragomir <alex.dragomir@gmail.com >
> > > wrote:
> > > > > > > I'm working on a component that expects a json response (..
> > > frankly ,
> > > > > > i'm
> > > > > > > not sure anymore about this)
> > > > > > >
> > > > > > > Is a dojo widget that i'm trying to convert into tapestry.
> > > > > > >
> > > > > > > A valid response would be :
> > > > > > >
> > > > > > > ({title: "a new title"})
> > > > > > >
> > > > > > > or even
> > > > > > >
> > > > > > > dojo.debug("server gave a new title"); ({title: "a new
> > > title"})
> > > > > > >
> > > > > > > The problem is that using the JSONWriter i get something like
> > > :
> > > > > > >
> > > > > > > {"title" : "a new title"} -> the title is quoted and i think
> > > that is why
> > > > > > i
> > > > > > > get  an error saying  SyntaxError: invalid label
> > > > > > >
> > > > > > > If i don't use JSON response , i use XML , which is not good
> > > either.
> > > > > > >
> > > > > > > Any suggestion of what i'm doing wrong ?
> > > > > > > Should i build a custom ResponseBuilder or Writer ?
> > > > > > >
> > > > > > > thanks!
> > > > > > > Alex
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Jesse Kuhnert
> > > > > > Tapestry/Dojo team member/developer
> > > > > >
> > > > > > Open source based consulting work centered around
> > > > > > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> > > > > >
> > > > > >
> > > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > Jesse Kuhnert
> > > > Tapestry/Dojo team member/developer
> > > >
> > > > Open source based consulting work centered around
> > > > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> > > >
> > >
> > >
> > > --
> > > Jesse Kuhnert
> > > Tapestry/Dojo team member/developer
> > >
> > > Open source based consulting work centered around
> > > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
>

Re: using json response

Posted by Alexandru Dragomir <al...@gmail.com>.
I've been looking into TreeRpcControllerV3.js and TreeEditor.js for the
place where the response is handled , but i haven't got any result beside a
headache.. :)

Any suggestion is welcome !

Alex


On 12/17/06, Alexandru Dragomir <al...@gmail.com> wrote:
>
> I tried it but is still not working.
>
> But i found something else. I manage to hook the JSONWriterImpl and send
> whatever plain text i want to the client.
> When i send the string : ({title: 'a new title'}) is working.
> When i send the string : {title: 'a new title'} is not  working.
>
> So the conclusion is that  the brackets  "()" must be sent.
>
> Is this the way the widget should work ?
> Maybe i should put this question to dojo list ?
>
> thanks!
> Alex
>
> On 12/16/06, Jesse Kuhnert <jk...@gmail.com> wrote:
> >
> > Maybe the tree widget is expecting a json array vs object being
> > returned...Ie ["title","a new title"]. You can do that easily by doing
> > this instead:
> >
> > JSONArray arr = writer.array();
> > arr.put ("title");
> > arr.put("a new title");
> >
> >
> >
> > On 12/16/06, Jesse Kuhnert <jk...@gmail.com> wrote:
> > > Yes, that should be fine. It is a perfectly valid JSON response. There
> >
> > > aren't too many ways to vary it.
> > >
> > > On 12/16/06, Alexandru Dragomir <al...@gmail.com> wrote:
> > > > ok, then i might be doing something else wrong..
> > > > Is the tree widget.
> > > > And now i'm at editing a node label phase.
> > > > I edit , press enter , and the response received is  {"title" : "a
> > new
> > > > title"} without other brackets.
> > > >
> > > > The render method is
> > > > public void renderComponent(IJSONWriter writer, IRequestCycle cycle)
> > > >     {
> > > >
> > > >         JSONObject json = writer.object();
> > > >         json.put("title", "a new title");
> > > >      }
> > > >
> > > > Alex
> > > >
> > > >
> > > > On 12/16/06, Jesse Kuhnert < jkuhnert@gmail.com> wrote:
> > > > >
> > > > > Quoting/not quoting a response should have nothing to do with it
> > being
> > > > > valid JSON. Nor should a response contain the surrounding "("
> > content
> > > > > ")".
> > > > >
> > > > > I'd be interested in knowing which dojo widget this is but if it's
> > > > > using dojo.io as the transport layer it should be adding in the
> > "("
> > > > > for you.
> > > > >
> > > > > On 12/16/06, Alexandru Dragomir <al...@gmail.com> wrote:
> > > > > > I'm working on a component that expects a json response (..
> > frankly ,
> > > > > i'm
> > > > > > not sure anymore about this)
> > > > > >
> > > > > > Is a dojo widget that i'm trying to convert into tapestry.
> > > > > >
> > > > > > A valid response would be :
> > > > > >
> > > > > > ({title: "a new title"})
> > > > > >
> > > > > > or even
> > > > > >
> > > > > > dojo.debug("server gave a new title"); ({title: "a new title"})
> > > > > >
> > > > > > The problem is that using the JSONWriter i get something like :
> > > > > >
> > > > > > {"title" : "a new title"} -> the title is quoted and i think
> > that is why
> > > > > i
> > > > > > get  an error saying  SyntaxError: invalid label
> > > > > >
> > > > > > If i don't use JSON response , i use XML , which is not good
> > either.
> > > > > >
> > > > > > Any suggestion of what i'm doing wrong ?
> > > > > > Should i build a custom ResponseBuilder or Writer ?
> > > > > >
> > > > > > thanks!
> > > > > > Alex
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Jesse Kuhnert
> > > > > Tapestry/Dojo team member/developer
> > > > >
> > > > > Open source based consulting work centered around
> > > > > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> > > > >
> > > > >
> > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > Jesse Kuhnert
> > > Tapestry/Dojo team member/developer
> > >
> > > Open source based consulting work centered around
> > > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> > >
> >
> >
> > --
> > Jesse Kuhnert
> > Tapestry/Dojo team member/developer
> >
> > Open source based consulting work centered around
> > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>

Re: using json response

Posted by Alexandru Dragomir <al...@gmail.com>.
I tried it but is still not working.

But i found something else. I manage to hook the JSONWriterImpl and send
whatever plain text i want to the client.
When i send the string : ({title: 'a new title'}) is working.
When i send the string : {title: 'a new title'} is not  working.

So the conclusion is that  the brackets  "()" must be sent.

Is this the way the widget should work ?
Maybe i should put this question to dojo list ?

thanks!
Alex

On 12/16/06, Jesse Kuhnert <jk...@gmail.com> wrote:
>
> Maybe the tree widget is expecting a json array vs object being
> returned...Ie ["title","a new title"]. You can do that easily by doing
> this instead:
>
> JSONArray arr = writer.array();
> arr.put("title");
> arr.put("a new title");
>
>
>
> On 12/16/06, Jesse Kuhnert <jk...@gmail.com> wrote:
> > Yes, that should be fine. It is a perfectly valid JSON response. There
> > aren't too many ways to vary it.
> >
> > On 12/16/06, Alexandru Dragomir <al...@gmail.com> wrote:
> > > ok, then i might be doing something else wrong..
> > > Is the tree widget.
> > > And now i'm at editing a node label phase.
> > > I edit , press enter , and the response received is  {"title" : "a new
> > > title"} without other brackets.
> > >
> > > The render method is
> > > public void renderComponent(IJSONWriter writer, IRequestCycle cycle)
> > >     {
> > >
> > >         JSONObject json = writer.object();
> > >         json.put("title", "a new title");
> > >      }
> > >
> > > Alex
> > >
> > >
> > > On 12/16/06, Jesse Kuhnert <jk...@gmail.com> wrote:
> > > >
> > > > Quoting/not quoting a response should have nothing to do with it
> being
> > > > valid JSON. Nor should a response contain the surrounding "("
> content
> > > > ")".
> > > >
> > > > I'd be interested in knowing which dojo widget this is but if it's
> > > > using dojo.io as the transport layer it should be adding in the "("
> > > > for you.
> > > >
> > > > On 12/16/06, Alexandru Dragomir <al...@gmail.com> wrote:
> > > > > I'm working on a component that expects a json response (..
> frankly ,
> > > > i'm
> > > > > not sure anymore about this)
> > > > >
> > > > > Is a dojo widget that i'm trying to convert into tapestry.
> > > > >
> > > > > A valid response would be :
> > > > >
> > > > > ({title: "a new title"})
> > > > >
> > > > > or even
> > > > >
> > > > > dojo.debug("server gave a new title"); ({title: "a new title"})
> > > > >
> > > > > The problem is that using the JSONWriter i get something like :
> > > > >
> > > > > {"title" : "a new title"} -> the title is quoted and i think that
> is why
> > > > i
> > > > > get  an error saying  SyntaxError: invalid label
> > > > >
> > > > > If i don't use JSON response , i use XML , which is not good
> either.
> > > > >
> > > > > Any suggestion of what i'm doing wrong ?
> > > > > Should i build a custom ResponseBuilder or Writer ?
> > > > >
> > > > > thanks!
> > > > > Alex
> > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > Jesse Kuhnert
> > > > Tapestry/Dojo team member/developer
> > > >
> > > > Open source based consulting work centered around
> > > > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > >
> > > >
> > >
> > >
> >
> >
> > --
> > Jesse Kuhnert
> > Tapestry/Dojo team member/developer
> >
> > Open source based consulting work centered around
> > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> >
>
>
> --
> Jesse Kuhnert
> Tapestry/Dojo team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: using json response

Posted by Jesse Kuhnert <jk...@gmail.com>.
Maybe the tree widget is expecting a json array vs object being
returned...Ie ["title","a new title"]. You can do that easily by doing
this instead:

JSONArray arr = writer.array();
arr.put("title");
arr.put("a new title");



On 12/16/06, Jesse Kuhnert <jk...@gmail.com> wrote:
> Yes, that should be fine. It is a perfectly valid JSON response. There
> aren't too many ways to vary it.
>
> On 12/16/06, Alexandru Dragomir <al...@gmail.com> wrote:
> > ok, then i might be doing something else wrong..
> > Is the tree widget.
> > And now i'm at editing a node label phase.
> > I edit , press enter , and the response received is  {"title" : "a new
> > title"} without other brackets.
> >
> > The render method is
> > public void renderComponent(IJSONWriter writer, IRequestCycle cycle)
> >     {
> >
> >         JSONObject json = writer.object();
> >         json.put("title", "a new title");
> >      }
> >
> > Alex
> >
> >
> > On 12/16/06, Jesse Kuhnert <jk...@gmail.com> wrote:
> > >
> > > Quoting/not quoting a response should have nothing to do with it being
> > > valid JSON. Nor should a response contain the surrounding "(" content
> > > ")".
> > >
> > > I'd be interested in knowing which dojo widget this is but if it's
> > > using dojo.io as the transport layer it should be adding in the "("
> > > for you.
> > >
> > > On 12/16/06, Alexandru Dragomir <al...@gmail.com> wrote:
> > > > I'm working on a component that expects a json response (.. frankly ,
> > > i'm
> > > > not sure anymore about this)
> > > >
> > > > Is a dojo widget that i'm trying to convert into tapestry.
> > > >
> > > > A valid response would be :
> > > >
> > > > ({title: "a new title"})
> > > >
> > > > or even
> > > >
> > > > dojo.debug("server gave a new title"); ({title: "a new title"})
> > > >
> > > > The problem is that using the JSONWriter i get something like :
> > > >
> > > > {"title" : "a new title"} -> the title is quoted and i think that is why
> > > i
> > > > get  an error saying  SyntaxError: invalid label
> > > >
> > > > If i don't use JSON response , i use XML , which is not good either.
> > > >
> > > > Any suggestion of what i'm doing wrong ?
> > > > Should i build a custom ResponseBuilder or Writer ?
> > > >
> > > > thanks!
> > > > Alex
> > > >
> > > >
> > >
> > >
> > > --
> > > Jesse Kuhnert
> > > Tapestry/Dojo team member/developer
> > >
> > > Open source based consulting work centered around
> > > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
> >
>
>
> --
> Jesse Kuhnert
> Tapestry/Dojo team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

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

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


Re: using json response

Posted by Jesse Kuhnert <jk...@gmail.com>.
Yes, that should be fine. It is a perfectly valid JSON response. There
aren't too many ways to vary it.

On 12/16/06, Alexandru Dragomir <al...@gmail.com> wrote:
> ok, then i might be doing something else wrong..
> Is the tree widget.
> And now i'm at editing a node label phase.
> I edit , press enter , and the response received is  {"title" : "a new
> title"} without other brackets.
>
> The render method is
> public void renderComponent(IJSONWriter writer, IRequestCycle cycle)
>     {
>
>         JSONObject json = writer.object();
>         json.put("title", "a new title");
>      }
>
> Alex
>
>
> On 12/16/06, Jesse Kuhnert <jk...@gmail.com> wrote:
> >
> > Quoting/not quoting a response should have nothing to do with it being
> > valid JSON. Nor should a response contain the surrounding "(" content
> > ")".
> >
> > I'd be interested in knowing which dojo widget this is but if it's
> > using dojo.io as the transport layer it should be adding in the "("
> > for you.
> >
> > On 12/16/06, Alexandru Dragomir <al...@gmail.com> wrote:
> > > I'm working on a component that expects a json response (.. frankly ,
> > i'm
> > > not sure anymore about this)
> > >
> > > Is a dojo widget that i'm trying to convert into tapestry.
> > >
> > > A valid response would be :
> > >
> > > ({title: "a new title"})
> > >
> > > or even
> > >
> > > dojo.debug("server gave a new title"); ({title: "a new title"})
> > >
> > > The problem is that using the JSONWriter i get something like :
> > >
> > > {"title" : "a new title"} -> the title is quoted and i think that is why
> > i
> > > get  an error saying  SyntaxError: invalid label
> > >
> > > If i don't use JSON response , i use XML , which is not good either.
> > >
> > > Any suggestion of what i'm doing wrong ?
> > > Should i build a custom ResponseBuilder or Writer ?
> > >
> > > thanks!
> > > Alex
> > >
> > >
> >
> >
> > --
> > Jesse Kuhnert
> > Tapestry/Dojo team member/developer
> >
> > Open source based consulting work centered around
> > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

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

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


Re: using json response

Posted by Alexandru Dragomir <al...@gmail.com>.
ok, then i might be doing something else wrong..
Is the tree widget.
And now i'm at editing a node label phase.
I edit , press enter , and the response received is  {"title" : "a new
title"} without other brackets.

The render method is
public void renderComponent(IJSONWriter writer, IRequestCycle cycle)
    {

        JSONObject json = writer.object();
        json.put("title", "a new title");
     }

Alex


On 12/16/06, Jesse Kuhnert <jk...@gmail.com> wrote:
>
> Quoting/not quoting a response should have nothing to do with it being
> valid JSON. Nor should a response contain the surrounding "(" content
> ")".
>
> I'd be interested in knowing which dojo widget this is but if it's
> using dojo.io as the transport layer it should be adding in the "("
> for you.
>
> On 12/16/06, Alexandru Dragomir <al...@gmail.com> wrote:
> > I'm working on a component that expects a json response (.. frankly ,
> i'm
> > not sure anymore about this)
> >
> > Is a dojo widget that i'm trying to convert into tapestry.
> >
> > A valid response would be :
> >
> > ({title: "a new title"})
> >
> > or even
> >
> > dojo.debug("server gave a new title"); ({title: "a new title"})
> >
> > The problem is that using the JSONWriter i get something like :
> >
> > {"title" : "a new title"} -> the title is quoted and i think that is why
> i
> > get  an error saying  SyntaxError: invalid label
> >
> > If i don't use JSON response , i use XML , which is not good either.
> >
> > Any suggestion of what i'm doing wrong ?
> > Should i build a custom ResponseBuilder or Writer ?
> >
> > thanks!
> > Alex
> >
> >
>
>
> --
> Jesse Kuhnert
> Tapestry/Dojo team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: using json response

Posted by Jesse Kuhnert <jk...@gmail.com>.
Quoting/not quoting a response should have nothing to do with it being
valid JSON. Nor should a response contain the surrounding "(" content
")".

I'd be interested in knowing which dojo widget this is but if it's
using dojo.io as the transport layer it should be adding in the "("
for you.

On 12/16/06, Alexandru Dragomir <al...@gmail.com> wrote:
> I'm working on a component that expects a json response (.. frankly , i'm
> not sure anymore about this)
>
> Is a dojo widget that i'm trying to convert into tapestry.
>
> A valid response would be :
>
> ({title: "a new title"})
>
> or even
>
> dojo.debug("server gave a new title"); ({title: "a new title"})
>
> The problem is that using the JSONWriter i get something like :
>
> {"title" : "a new title"} -> the title is quoted and i think that is why i
> get  an error saying  SyntaxError: invalid label
>
> If i don't use JSON response , i use XML , which is not good either.
>
> Any suggestion of what i'm doing wrong ?
> Should i build a custom ResponseBuilder or Writer ?
>
> thanks!
> Alex
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

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

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