Create RESTful services with Dojo and Jax-rs

Source: Internet
Author: User
Tags file system json connect pack web services client

Easy implementation on the client and server side

The latest version of Ibm®websphere®application Server Feature Pack for WEB 2.0 provides an end-to-end solution for creating an Ajax style architecture. On the client side, the feature package provides open source Dojo JavaScript Toolbox. Jax-rs (based on the Apache Wink project) provides a server-side library in the latest version of the feature Pack to enable RESTful services to connect to Dojo.

In addition to a wide range of user interface widgets, Dojo provides a rich data service API that makes it easy to connect to server-side WEB services. The Dojo Data API abstracts the unique data format concept from widgets that display the user interface. Dojo data provides the basic data store to read JSON data, and there are other formats, such as Xmlstore, Csvstore, and so on. If you use Dojo's tree widgets, you can select the data store you want to use, and the data store is responsible for the tree widget data processing service.

Dojo's data store is easy to connect to the RESTful service, and the RESTful service introduces Jax-rs. The Jax-rs Apache Wink implementation makes it easy to create your own custom WEB services. So if you want to, say, use Dojo's Tree widget to describe the file system representation, you need to implement the protocol Dojo usage to describe the file system representation. When Dojo provides you with client services, you also need to write to the server-side implementation. Jax-rs helps the server implementation become simple and understandable.

An example

Let's use an example to illustrate. Figure 1 shows the interaction between the client and server side. In this example, you can display the original FIFA World Cup soccer team in a table of contents format. You can use the directory structure on the server side to create a tree representation on the client. On the left, Diji. Tree is a Dojo UI widget that is used to display directory information contained in a server. Dijit.tree relies on Dijt.tree.ForestStoreModel and Dojox.data.FileStore. Dijit.tree.ForestStoreModel is a mapping layer between the data returned from the Dojox.data.FileStore. Foreststoremodel is responsible for creating a "Files" containing the directory virtual root node and is responsible for putting everything under the root node. Dojox.data.FileStore is responsible for opening the server-side RESTful service connection with the JAX-RS implementation.

The server side runs a RESTful service that implements the Rest/filestore/filelist request. The Jax-rs service reads HTTP GET requests from Dojox.data.FilesStore and returns the data to Dojo.data.FileStore in JSON format. The format returned by the data is Json,dojox.data.filestore support for this format.

Figure 1. RESTful interaction between server-side and client

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.