Turbine Services - JSON-RPC Service Scott Eade

The JSON-RPC Service supports JavaScript to Java AJAX communications using JSON-RPC-Java (Jabsorb replaced project oss.metaparadigm.com/jsonrpc/. As of March 2015 Google Code projects are only read-only and this project is archived too, though GIT exports are allowed probably until Jan 2016, e.g. https://github.com/gmkll/jabsorb).

There are a number of things you need to do in order to add AJAX functionality to your webapp. First you implement the functions:

Next you implement your Screen class to make your functions available:

Now we shift focus to your template classes. Firstly, there are a few useful utility functions that you need to make sure are available to the pages that will include AJAX functionality:

In these pages you also need to include the JavaScript necessary to process the JSON calls - this file is available as part of the JSON-RPC Java distribution (it is included in the webapps\jsonrpc directory):

Then you need to set up the specific handler for the page (synchronous example):

]]>

Alternatively, asynchronous calls require handling of the deferred objects, which could be done by using some kind of Promise) library. As an example a JQuery Promise Object model (supported since version 1.5) is shown. Usage of asynchronous calls conforms more to XMLHttpRequest specification.

In these pages you also need to include the JavaScript necessary to process the JSON calls - this file is available as part of the JSON-RPC-Java distribution (it is included in the webapps\jsonrpc directory):

Then you need to set up the specific handler for the page (in this case a asynchronous handler):

]]>

The above code is executable by users that are not logged into your application. Your Screen class can extend JSONSecureScreen to require that users be logged in before allowing execution.