I have created a new project, called JSON and REST Samples (direct download).

REST services and JSON have become more and more popular. Providing REST/JSON services opens up new capabilities to consume XPages application functionality in other types of applications. Additionally existing Dojo UI controls can be used and data can easily be bound to them. Furthermore the clean separation of the services and data on one hand side and the UI/markup on the other hand side allows easy caching and enables offline capabilities.

This project shows simple samples for how to handle JSON.

The XPages runtime comes with it's own JSON library (e.g. com.ibm.commons.util.io.json.JsonJavaFactory) allowing the implementation of REST services using JSON. The XPages Extension Library includes already REST services for view entries. This project shows how to provide custom REST services for data from somewhere else (in this case from one document) and it shows how to do this without the extension library as prereq. While the mechanism in the extension library is more sophisticated, this sample shows a pragmatic interim solution.

The project also shows how to consume the REST/JSON services on client side. One XPage shows how to get the output of a service call in a JavaScript object.
Another XPage shows how to bind a REST service to a Dojo data grid control. This control can be populated via a REST GET requests. Furthermore cell values can be changed and be written back via REST PUT requests.

This screenshot shows (a non styled) data grid control reading from and writing to NSFs using a custom REST service:

A picture named M2

comments powered byDisqus