[deepamehta-devel] Question About the Webclients Controller

Jörg Richter jri at deepamehta.de
Di Jan 28 17:51:40 CET 2014


Yes, you can access the DM Core Service from a 3rd-party Webclient by loading and instantiating DM's RESTClient, which is part of the dm4-webclient module:
https://github.com/jri/deepamehta/blob/master/modules/dm4-webclient/src/main/resources/web/script/util/rest_client.js

The RESTClient is standalone. It does not depend on any DM client-side code. However, it depends (for the moment) on jQuery.

You can either bundle rest_client.js with your plugin, or, you can load the DM Webclient's one (provided this module is included in your installation):

	<script src="/de.deepamehta.webclient/script/util/rest_client.js"></script> 

Then your plugin can instantiate a RESTClient and send requests to the DM Core Service:

	var restc = new RESTClient()
	var topic = restc.get_topic_by_id(1234)

For available methods and for RESTClient constructor options look inside the rest_client.js source.

In case you need other services of the DM standard distro (besides the Core Service), e.g. the Topicmaps Service, you can enrich your RESTClient instance as needed.

	restc.get_topicmap = function(topicmap_id) {
		return this.request("GET", "/topicmap/" + topicmap_id)
	}

For available methods see the === REST Client Extension === section at the beginning of the respective module's plugin.js file.

Sending a request to the Topicmaps Service is straight-forward then:

	var topicmap = restc.get_topicmap(2345)

For the service to be provided the respective module (here: DM4 Topicmaps) must be included in your installation. Your RESTClient is still standalone and does not rely on the client-side Topicmaps code.

To enrich your RESTClient instance with methods for accessing your own service (in case your plugin provides one) you would use the very same approach.

Cheers,
Jörg


On Jan 27, 2014, at 21:28, Jörn Weißenborn wrote:

> Hi,
> 
> Is it possible, e.g. by embedding the js file with a script tag, to include and employ the dm4s service in a third party web applications?
> 
> Best,
> 
> Joern




Mehr Informationen über die Mailingliste devel