DA JavaScript

Hi

We needed to adjust the DataAbstract.js for further implementation in Delphi web-applications.
Maybe this is necessary in an update of DA for JavaScript.

//    RemoteDataAdapter : function RemoteDataAdapter(aDataService, aLoginService, aStreamerClass) { //old api
RemoteDataAdapter: function RemoteDataAdapter(aURL, aDataServiceName, aLoginServiceName, aStreamerClass) {
 var that = this;
/*****************************************************************************
* modified this file on Aug 28, 2024.
*
* the old API allowed for the user to pass a DataService and a LoginService
* by *reference* (not a DataService and a LoginService by *name*).
* 
* unfortunately, this RemoteDataAdapter implemention needed both services to
* derive from RemObjects.SDK.RemoteService.
* 
* in practice, you might want to pass a DataService that derives from
* RemObjects.DataAbstract.Server.DataAbstractService and/or a LoginService
* that derives from RemObjects.DataAbstract.Server.BaseLoginService.
* 
* starting with Aug 28, 2024 this RemoteDataAdapter implementation allows for...
* 1. DataService to derive from...
*    1.1 RemObjects.SDK.RemoteService, or
*    1.2 RemObjects.DataAbstract.Server.DataAbstractService
* 2. LoginService to derive from...
*    2.1 RemObjects.SDK.RemoteService, or
*    2.2 RemObjects.DataAbstract.Server.BaseLoginService
*****************************************************************************/
 if (arguments[0] instanceof RemObjects.DataAbstract.Server.DataAbstractService) {
	 this.fService = arguments[0];
 } else {
	 this.fService = new RemObjects.DataAbstract.Server.DataAbstractService(arguments[0]);
 }
 this.fLoginService = new RemObjects.SDK.RemoteService(
	 this.fService.fChannel,
	 this.fService.fMessage,
	 'LoginService'
 );

Regards,
Filip

Hi,

can you give examples, why you can’t use std implementation, pls?

for example:

LoginService that derives from RemObjects.DataAbstract.Server.BaseLoginService

when you pass loginstring like

			adapter = new RemObjects.DataAbstract.RemoteDataAdapter(
				serverUrl,
				"DataService"
			);

			adapter.login(
				"user=aaa;password=bbb",
				loadData,
				RemObjects.UTIL.ShowError
			);

internally it creates BaseLoginService instance and calls his LoginEx method

    case 1: //loginString
      svc = new RemObjects.DataAbstract.Server.BaseLoginService(this.fLoginService);
      svc.LoginEx(arguments[0], arguments[1], arguments[2]);
      break;

Hello Evgeny,

Thank you for your reply.

We modified the old API included with DataAbstract.js, not the new API.

Both APIs included with DataAbstract.js are documented here: RemoteDataAdapter.

The new API allows for the user to pass a DataServer and LoginService by name. But the old API allowed for the user to pass a DataService and LoginService by reference.

We have legacy projects that consume the old API.

Unfortunately, the old API included with DataAbstract.js wanted both services to derive from RemObjects.SDK.RemoteService. It would not accept any other services.

However, in practice you might want to pass a DataService that derives from RemObjects.DataAbstract.Server.DataAbstractService and/or a LoginService that derives from RemObjects.DataAbstract.Server.BaseLoginService. I know we do.

We modifed DataAbstract.js so that it allows for a DataService to derive from…

  1. RemObjects.SDK.RemoteService, or
  2. RemObjects.DataAbstract.Server.DataAbstractService

and a LoginService to derive from…

  1. RemObjects.SDK.RemoteService, or
  2. RemObjects.DataAbstract.Server.BaseLoginService

Thanks!

Hi,

You haven’t answered to my question:
why you can’t use a new api with url, like

var rda = new RemObjects.DataAbstract.RemoteDataAdapter("http://localhost:8099/json");
//Defaults are:
//data service name = "DataService"
//login service name = "LoginService"
//streamer class = Bin2DataStreamer

and need to pass services by reference?
can you give examples when new api does not cover your needs?

Hello Evgeny,

Thank you for your reply.

The new API does cover our needs, but we have legacy projects that consume the old API.

Just wanted to inform you about the old API being broken for us, and how we fixed it.

Thanks!