Using the KUIB, how to pass a parameter with every servercal

Posted by p4m on 06-Dec-2016 12:07

Hi,
we need to pass a session-id with any server-call. The session-id is created on the server and returned by our (individual) login-call. 

We considered to add an additional field in the temp-table of the business entites, like there is already one for the ROWID and the sequence-number as it is used for serverside-paging.

This would fit for the update and delete calls.
For the read-calls we had the idea to  expand the capabilities
@openapi.openedge.method.property (name="mappingType", value="JFP").
@openapi.openedge.method.property (name="capabilities", value="ablFilter,top,skip,id,orderBy,ppSid").

Our questions are:
is there a recommended way to pass an additional parameter with any server call?
how to implement the additional capability (ppSID) in the app/KUIB? Any modification of progress.all.js results in an reference error  "progress is not defined"
If the use of the client-principal is a solution, so how to use it with the KUIB?

many thanks in advance

Wolfgang

 

 

All Replies

Posted by egarcia on 06-Dec-2016 15:50

Hello Wolfgang,

What type of Data Object are you using? REST or Web transport?

Is it your own REST service?

Depending on the type of data service, you might be able to APIs in the JSDOSession that allows you to send/receive context to/from the server.

To implement the additional capability ppSID, you would need to override the default JFP plugin or add your own plugin "MYJFP".

See the following post for some information on the usage of MappingType plugins: community.progress.com/.../69540

In practice, it is easier to add your own "MYJFP" plugin.

You need to register the new plugin before the READ operation is performed.

Here is a sample function that registers a "MYJFP" plugin which extends the JFP plugin.

The MYJFP plugin uses the JSDO.getProperty() API to access a mydata property. (Your ppSID property.)

   function registerPlugin() {

       var jfpPlugin = progress.data.PluginManager.getPlugin("JFP");

       progress.data.PluginManager.addPlugin("MYJFP", {

           requestMapping: function (jsdo, params, info) {

               var requestParams = {},

                   object = {};

               params = jfpPlugin.requestMapping(jsdo, params, info);

               if (params && typeof params.filter === "string") {

                   object = JSON.parse(params.filter);

               }

               object.mydata = jsdo.getProperty("mydata");

               requestParams.filter = JSON.stringify(object);

               return requestParams;

           }

       });

   }

From your code, you would need to access the JSDO from the Kendo UI DataSource.

For example, you access the JSDO from the Kendo UI Grid on a row select event using the following code:

onRowSelect: function(e) {

   e.sender.dataSource.transport.jsdo.setProperty("mydata", "TESTDATA");

}

Note: You specify the code for onRowSelect in the src/scripts/<view-name>/view-factory.js file.

On the ABL side, in the Business Entity class, you would access mydata by querying the property in the jsonObject variable.

   jsonParser  = NEW ObjectModelParser().

   ...

   cOrderBy    = jsonObject:GetCharacter("orderBy") NO-ERROR.

   mydata      = jsonObject:GetCharacter("mydata") NO-ERROR.

Please let me know if you need more information.

Cheers.

Posted by p4m on 07-Dec-2016 15:39

Hello Edsel,

I use a REST Data Object create by myself.

Following your advice I registered the MYJFP-plugin, implemeted the setProperty onRowSelect and got mydata on the ABL side. Now I want to the set the property before the first server call. Would this be onInit? Is the dataSource there already available and how to set the property in the onInit section?

thanks in advance

wolfgang

Posted by egarcia on 08-Dec-2016 14:08

Hello Wolfgang,

The onInit event might be too early to set the property on the JSDO instance.

A possible approach is to add a watch on the onShow event that would monitor changes to the grid component.

Example:

$scope.$watch(function() {

return angular.element('[data-role="grid"]').data("kendoGrid");

}, function(newValue, oldValue) {

var grid;

if (newValue) {

console.log("DEBUG: " + newValue);

grid = newValue;

console.log("DEBUG: " + grid.dataSource.transport.jsdo);

}

});

I hope this helps,

Edsel

This thread is closed