cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Johnston <coc...@lojjic.net>
Subject Re: JSON
Date Wed, 18 Oct 2006 01:23:16 GMT
Jeremy Quinn wrote:
> Hi Maurizio
> 
> I have not tried this yet, but my guess is you should output your JS 
> Object as a String
> 
> cocoon.sendPage("myTemplate.jx", {json: myObject.toSource()});
> 
> or similar
> 
> and send that to JXTemplate
> 
> <text>
> json: ${json}
> </text>
> 
> or similar
> 
> Then output that using the TextSerializer with a MimeType of 
> text/javascript (I think)


A simpler way would be to use the module: source in a reader to serve up 
the flow attribute:

cocoon.sendPage("send-json", {json : myObject.toSource()});

<map:match pattern="send-json">
   <map:read src="module:flow-attr:json" mime-type="text/javascript" />
</map:match>


> 
> A reference to the toSource function :
> http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object:toSource

> 
> 
> 
> HTH
> 
> regards Jeremy
> 
> 
> 
> On 15 Oct 2006, at 17:17, Maurizio P. wrote:
> 
>> Greetings to all.
>>
>> I would like to do a 'simple' JSON communication between browser and
>> server  flowscript (without using all these nice dojo's widgets). I mean,
>> is it possible for example to make a simple Array in flowscript and
>> send it in JSON to javascript running into browser, that asked it? I can
>> do it in PHP and i know it must be possible also in Cocoon (dojo does
>> much more!!), but still dunno how to do it.
>>
>> Is there an easy way or am i obliged to look for the ajax-block's java
>> files, try to understand what the hell it does, cutting down all
>> unwanted stuff, recompile and deploy as new generator?
>>
>> Let u know i am not an expert of Cocoon.
>>
>> Thanx 2 all who will help
>>
>>
>> --Regards,
>>                    Maurizio
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
> 


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


Mime
View raw message