You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Marc Portier <mp...@outerthought.org> on 2007/05/22 13:49:22 UTC

2.2 using cocoon-ajax-impl

Hi there,

I have a block that is dependant on cocoon-ajax-impl and wants to use 
the JSON script in there:

before http://svn.apache.org/viewvc?view=rev&revision=534148

the script was loaded via
cocoon.load("resource://org/apache/cocoon/ajax/system/System.JSON.js");

today it seems we should be using:
cocoon.load("resource://COB-INF/system/System.JSON.js");

which looks a bit odd, no?

am I missing some 2.2. feature to read in block-contexts? or
wouldn't we rather provide some servlet:ajax:resource/internal/**
into these things?

regards,
-marc=

Re: 2.2 using cocoon-ajax-impl

Posted by Marc Portier <mp...@outerthought.org>.

Grzegorz Kossakowski wrote:
> Marc Portier pisze:
>> Hi there,
>>
>> I have a block that is dependant on cocoon-ajax-impl and wants to use 
>> the JSON script in there:
>>
>> before http://svn.apache.org/viewvc?view=rev&revision=534148
>>
>> the script was loaded via
>> cocoon.load("resource://org/apache/cocoon/ajax/system/System.JSON.js");
>>
>> today it seems we should be using:
>> cocoon.load("resource://COB-INF/system/System.JSON.js");
>>
>> which looks a bit odd, no?
> 
> The second one should not work and even it does it's not reliable way to 
> access resources of other blocks.
> 

just for the record, and sorry for not being clear on this:

this _does_ work
(it is in fact the only way I got it to work)


>> am I missing some 2.2. feature to read in block-contexts? or
>> wouldn't we rather provide some servlet:ajax:resource/internal/**
>> into these things?
> 
> Yes. resource/internal/** is a way to go.
> 

thx for the confirmation

regards,
-marc=

Re: 2.2 using cocoon-ajax-impl

Posted by Grzegorz Kossakowski <gk...@apache.org>.
Marc Portier pisze:
> Hi there,
> 
> I have a block that is dependant on cocoon-ajax-impl and wants to use 
> the JSON script in there:
> 
> before http://svn.apache.org/viewvc?view=rev&revision=534148
> 
> the script was loaded via
> cocoon.load("resource://org/apache/cocoon/ajax/system/System.JSON.js");
> 
> today it seems we should be using:
> cocoon.load("resource://COB-INF/system/System.JSON.js");
> 
> which looks a bit odd, no?

The second one should not work and even it does it's not reliable way to access resources of other blocks.

> am I missing some 2.2. feature to read in block-contexts? or
> wouldn't we rather provide some servlet:ajax:resource/internal/**
> into these things?

Yes. resource/internal/** is a way to go.

-- 
Grzegorz Kossakowski
http://reflectingonthevicissitudes.wordpress.com/

Re: 2.2 using cocoon-ajax-impl

Posted by Jeremy Quinn <je...@apache.org>.
On 24 May 2007, at 08:01, Marc Portier wrote:

> anyways trying to explain the issue: System.JSON.js quite clearly  
> states that it only supports serialization of some basic types, and  
> collections and maps
>
> so people that want to serialize out custom java beans to JSON have  
> two options
>
> 1. add that functionality to the JSON stuff by overriding the  
> _serializeValue function (or using dojo-binding-like  -yes on the  
> server side- aop advise on it
>
> 2. convert their java-objects first to maps and collections of the  
> mentioned basic structures...
>

Hi Guys

Yes, the JSON serialization flowscript is really basic. I just did  
what was needed to solve a simple problem.

JSON supports so few datatypes.

regards Jeremy

Re: 2.2 using cocoon-ajax-impl

Posted by Marc Portier <mp...@outerthought.org>.

Grzegorz Kossakowski wrote:
> Marc Portier pisze:
>>> Yes. I did this way (I didn't touch paths, directory structure, 
>>> sitemap) because I didn't understand the stuff fully. There is only 
>>> one sample in Cocoon (in Forms) that uses this stuff but it does not 
>>> work up to date. I mentioned problem few times and asked for help, 
>>> last time here:
>>> http://article.gmane.org/gmane.text.xml.cocoon.devel/72629
>>>
>>
>> ok, sorry for not being around with plenty of time when that happened
> 
> No problem. I hope that you will be able to help with fixing that sample.
> 

Well, I am around now, but still not with 'plenty of time'
I am however on an assignment where ajax-json-cocoon22 should be working 
for me, so let's for now assume that somewhere along the way we get to 
fixing that sample as a side effect?

>>> I didn't know that some may want to use JSON js files directly 
>>> instead of calling sitemap in system. Now I think that all the 
>>> functionality 
>>
>> as far as I understand now, loading the System.JSON.js is the only way 
>> to  be able to add json-serialization for your own beans...
>>
>> But I have to say I would welcome a more Java based solution for that 
>> anyway (probably based on the www.json.org/java/ stuff)
>>
>> something that could register custom json serializers so the send-json 
>> pipe could actually serialize out all your domain models
> 
> Could you explain more what you mean? I really don't know JSON that much 
> (I know basics, though).
> 

same as me

anyways trying to explain the issue: System.JSON.js quite clearly states 
that it only supports serialization of some basic types, and collections 
and maps

so people that want to serialize out custom java beans to JSON have two 
options

1. add that functionality to the JSON stuff by overriding the 
_serializeValue function (or using dojo-binding-like  -yes on the server 
side- aop advise on it

2. convert their java-objects first to maps and collections of the 
mentioned basic structures...


both feel patchy to me at this moment, and I think json support should 
be thought off in a more systematic way as to be able to convert between 
json-notation, xml(sax) and plain java (business) objects more easily

(more below)

>>> should be moved to the root sitemap and necessary resources should be 
>>> shared via "resource/internal/**".
>>>
>>
>> I had the same feeling
> 
> Go for it! :-)
> 
>>> Giacomo, as you seem to be more experienced with the JSON, could take 
>>> care of doing that? I can help you with any trouble you encounter. If 
>>
>> I think it makes sense to talk about how we should be addressing the 
>> json serialization of custom beans...
> 
> As already explained I confused you Marc, and Giacomo (sorry guys). This 
> way, I was referring to you Marc as someone experienced with JSON.

I am gladly honoured, but still confused :-)
as I really don't think I am the expert on json around...

now, svn praise showed me jeremy added the JSON.js file originally I'm 
polling him off-list to see if he has any more educated opinion in this 
(that and if the provide json.js from the www.json.org site would be a 
valid alternative)

I also remember a really old post of Sylvain in this area 
http://bluxte.net/blog/2005-11/17-49-57.html suggesting we also should 
add a json serializer, which brings me back to my previous remark on the 
multiple conversions we need:


1. uploaded json strings should be readable into objects (some 
registered cocoon-component aka spring-bean in c22) and sax-streams 
(generator?)

note: that registered (spring) component should be extensible so 
readers/writers for specific object-types could be added

I would prefer a java component over the current js approach (with a 
need for overwrites or interception for extending functionality) as this 
stuff should be available without involving flowscript/rhino (ie also 
from apples, javaflow, actions or common pipelines)


2. data to be send as json strings could be originating as in memory 
objects (sendObject idea, probably using the same registered component) 
or from xml (serializer)


and while rethinking all of the above: converting first to standard 
objects, maps and collections (or even the JSONObject from 
http://www.json.org/java/) might provide a nice middle ground from where 
both xml and json could pick up, leaving the mentioned java-component to 
an extensible pojo to-from jsonObject convertor (needs more thought though)


> Can you move current functionality and then we could discuss about 
> alternatives?
> 

above should have the broader discussion started


but, just one more question before starting on the move:
are we still sharing block sources between cocoon 2.1 and cocoon 2.2. 
branches? and if so doe anyone have a clue on the impact over there?


regards,
-marc=

Re: 2.2 using cocoon-ajax-impl

Posted by Grzegorz Kossakowski <gk...@apache.org>.
Marc Portier pisze:
>> Yes. I did this way (I didn't touch paths, directory structure, 
>> sitemap) because I didn't understand the stuff fully. There is only 
>> one sample in Cocoon (in Forms) that uses this stuff but it does not 
>> work up to date. I mentioned problem few times and asked for help, 
>> last time here:
>> http://article.gmane.org/gmane.text.xml.cocoon.devel/72629
>>
> 
> ok, sorry for not being around with plenty of time when that happened

No problem. I hope that you will be able to help with fixing that sample.

>> I didn't know that some may want to use JSON js files directly instead 
>> of calling sitemap in system. Now I think that all the functionality 
> 
> as far as I understand now, loading the System.JSON.js is the only way 
> to  be able to add json-serialization for your own beans...
> 
> But I have to say I would welcome a more Java based solution for that 
> anyway (probably based on the www.json.org/java/ stuff)
> 
> something that could register custom json serializers so the send-json 
> pipe could actually serialize out all your domain models

Could you explain more what you mean? I really don't know JSON that much (I know basics, though).

>> should be moved to the root sitemap and necessary resources should be 
>> shared via "resource/internal/**".
>>
> 
> I had the same feeling

Go for it! :-)

>> Giacomo, as you seem to be more experienced with the JSON, could take 
>> care of doing that? I can help you with any trouble you encounter. If 
> 
> I think it makes sense to talk about how we should be addressing the 
> json serialization of custom beans...

As already explained I confused you Marc, and Giacomo (sorry guys). This way, I was referring to you Marc as someone experienced with JSON.
Can you move current functionality and then we could discuss about alternatives?

-- 
Grzegorz Kossakowski
http://reflectingonthevicissitudes.wordpress.com/

Re: 2.2 using cocoon-ajax-impl

Posted by Marc Portier <mp...@outerthought.org>.

Grzegorz Kossakowski wrote:
> Marc Portier pisze:
>> hm,
>> looks like I'm stumbling over a partial answer:
>>
>> http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-ajax/cocoon-ajax-impl/src/main/resources/META-INF/cocoon/spring/cocoon-ajax-impl-blockServlet.xml?view=markup 
>>
>>
>> I suppose the 2nd bean over there will cater for the 'system' references?
> 
> Yes. I did this way (I didn't touch paths, directory structure, sitemap) 
> because I didn't understand the stuff fully. There is only one sample in 
> Cocoon (in Forms) that uses this stuff but it does not work up to date. 
> I mentioned problem few times and asked for help, last time here:
> http://article.gmane.org/gmane.text.xml.cocoon.devel/72629
> 

ok, sorry for not being around with plenty of time when that happened

> I didn't know that some may want to use JSON js files directly instead 
> of calling sitemap in system. Now I think that all the functionality 

as far as I understand now, loading the System.JSON.js is the only way 
to  be able to add json-serialization for your own beans...

But I have to say I would welcome a more Java based solution for that 
anyway (probably based on the www.json.org/java/ stuff)

something that could register custom json serializers so the send-json 
pipe could actually serialize out all your domain models

wdot? (please be invited to start a discussion on this, and on how we 
can cater for custom dojo widgets in a flexible way as well by the way)

> should be moved to the root sitemap and necessary resources should be 
> shared via "resource/internal/**".
> 

I had the same feeling

> Giacomo, as you seem to be more experienced with the JSON, could take 
> care of doing that? I can help you with any trouble you encounter. If 

I think it makes sense to talk about how we should be addressing the 
json serialization of custom beans...

> you do so, don't forget to update docs: 
> http://cocoon.zones.apache.org/daisy/cdocs-ajax/g1/1350.html
> 

regards,
-marc=

Re: 2.2 using cocoon-ajax-impl

Posted by Grzegorz Kossakowski <gk...@apache.org>.
Giacomo Pati pisze:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> 
> 
> Grzegorz Kossakowski wrote:
> 
>> Giacomo, as you seem to be more experienced with the JSON, could take
> 
> What makes you believe I know anything about JSON. Sorry, have no clue about it.

Arggh! I'm very sorry. :(
I meant Marc instead of Giacomo, it's Fraud-like mistake (I was reading Giacomo's response to the other topic while responding to Marc).

Sorry again!

-- 
Grzegorz Kossakowski
http://reflectingonthevicissitudes.wordpress.com/

Re: 2.2 using cocoon-ajax-impl

Posted by Giacomo Pati <gi...@apache.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



Grzegorz Kossakowski wrote:

> Giacomo, as you seem to be more experienced with the JSON, could take

What makes you believe I know anything about JSON. Sorry, have no clue about it.

- --
Giacomo Pati
Otego AG, Switzerland - http://www.otego.com
Orixo, the XML business alliance - http://www.orixo.com

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4 (GNU/Linux)

iD8DBQFGU/nlLNdJvZjjVZARAvNFAKDIMfeO/4xlzCsgztpFMrLe2RKEVwCg8nh5
RmbWJzapc1UdPEL+i8U3MC4=
=txW7
-----END PGP SIGNATURE-----

Re: 2.2 using cocoon-ajax-impl

Posted by Grzegorz Kossakowski <gk...@apache.org>.
Marc Portier pisze:
> hm,
> looks like I'm stumbling over a partial answer:
> 
> http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-ajax/cocoon-ajax-impl/src/main/resources/META-INF/cocoon/spring/cocoon-ajax-impl-blockServlet.xml?view=markup 
> 
> 
> I suppose the 2nd bean over there will cater for the 'system' references?

Yes. I did this way (I didn't touch paths, directory structure, sitemap) because I didn't understand the stuff fully. There is only one 
sample in Cocoon (in Forms) that uses this stuff but it does not work up to date. I mentioned problem few times and asked for help, last 
time here:
http://article.gmane.org/gmane.text.xml.cocoon.devel/72629

I didn't know that some may want to use JSON js files directly instead of calling sitemap in system. Now I think that all the functionality 
should be moved to the root sitemap and necessary resources should be shared via "resource/internal/**".

Giacomo, as you seem to be more experienced with the JSON, could take care of doing that? I can help you with any trouble you encounter. If 
you do so, don't forget to update docs: http://cocoon.zones.apache.org/daisy/cdocs-ajax/g1/1350.html

-- 
Grzegorz Kossakowski
http://reflectingonthevicissitudes.wordpress.com/

Re: 2.2 using cocoon-ajax-impl

Posted by Marc Portier <mp...@outerthought.org>.
hm,
looks like I'm stumbling over a partial answer:

http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-ajax/cocoon-ajax-impl/src/main/resources/META-INF/cocoon/spring/cocoon-ajax-impl-blockServlet.xml?view=markup

I suppose the 2nd bean over there will cater for the 'system' references?



although I don't see the matching sitemap to deliver the goodies?

http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-ajax/cocoon-ajax-impl/src/main/resources/COB-INF/system/sitemap.xmap?view=markup


will need some more digging later,
any upfront clarifications welcome


regards,
-marc=




Marc Portier wrote:
> Hi there,
> 
> I have a block that is dependant on cocoon-ajax-impl and wants to use 
> the JSON script in there:
> 
> before http://svn.apache.org/viewvc?view=rev&revision=534148
> 
> the script was loaded via
> cocoon.load("resource://org/apache/cocoon/ajax/system/System.JSON.js");
> 
> today it seems we should be using:
> cocoon.load("resource://COB-INF/system/System.JSON.js");
> 
> which looks a bit odd, no?
> 
> am I missing some 2.2. feature to read in block-contexts? or
> wouldn't we rather provide some servlet:ajax:resource/internal/**
> into these things?
> 
> regards,
> -marc=
>