Convert 'compositeData' to a 'json object' in client javascript

var compositeDataJson = dojo.fromJson('#{javascript:var compositeDataObj = new;compositeDataObj.putAll(compositeData);return compositeDataObj.toString()}');

Previously I always used Google's 'GSON' to convert  the compositeData object (=all properties in your custom control) to a string.
Now this code does not use this third party plugin anymore but just uses an build in method from the extension library.

If you write for example custom Dojo widgets, you could 'wrap' your widget inside an custom control and 'pass' the full compositeData object to your widget.

JavaScript (Client)
F. Kranenburg
September 6, 2014 5:15 AM

All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.

1 comment(s)Login first to comment...
Oliver Busse
(at 09:07 on 06.09.2014)
Very nice one!