Log In | Sign Up   View a printable version of the current page.
  Dashboard > flexive > ... > Developer Info > JSON RPC Integration

Added by Markus Plesser, last edited by Markus Plesser on Dec 07, 2007  (view change)
Labels: 
(None)

JSON-RPC Integration

The Javascript Object Notation (JSON) is a format for exchanging data, especially between javascript clients and remote servers. Its main advantages are ease of use (including native client-side parsing with Javascript's eval method) and portability.

JSON/RPC provides a convenient and portable way for remote procedure where both request and response are represented in JSON notation. Results can be turned to objects immediately through eval.

Client-Side Calls of Remote Procedures

The JavaScript client invokes a remote method using the interface of the Java method. The result (typically a String containing JSON and/or javascript code) is then returned to the client layer. A callback function is used to notify the client of the result, including error messages raised through exceptions on the server side. The call is typically asynchronous, meaning that the client continues to operate as the request is being processed.

Serverside Calls to JSON/RPC Objects

Since the objects providing JSON methods are just POJOs, they can be used on the server-side too. When rendering a page with a JSON-capable component, it makes sense to pass the initial data to the component during rendering and not using an extra call. Thus, a Facelets wrapper tag is available for calling JSON/RPC methods on a JSF page:

  • method: the method to be executed. Includes the object on which the method should be invoked, which must be registered with the user's JSON/RPC bridge.
  • args: comma-separated arguments for the method. Currently only scalar values are supported.

Example

<!-- Call ContentTreeWriter.renderContentTree(1, 2, false) and render the result. -->
<fx:jsonRpcCall method="ContentTreeWriter.renderContentTree" args="1, 2, false"/>
Site running on a free Atlassian Confluence Open Source Project License granted to [fleXive] . Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.6.1 Build:#916 Nov 09, 2007) - Bug/feature request - Contact Administrators