12.07.2015 Views

JSON-RPC - Custom Training Courses - Coreservlets.com

JSON-RPC - Custom Training Courses - Coreservlets.com

JSON-RPC - Custom Training Courses - Coreservlets.com

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Returning Complex Data:Example (Results)3738Complex Data: Returning Listsor Arrays• Server-side code– Specify return type as List or Type[]• Client-side code– Get the “list” property (not the direct return value)– This is an array (probably of <strong>JSON</strong>ified beans)• Examplevar callback = function(cityList, exception) {if(exception) {alert(exception.msg);} else {doSomethingWith(cityList.list);}};Note: http://jabsorb.org/Manual says to use“exception.message message” . However, debugging withFirebug shows that it is “exception.msg” in thecurrent release.Even though remote method returns List, theconverted List (array) does not go into the top-levelvariable (cityList). Instead, it gets put into anautomatically-created property called “list”.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!