Skip to Content
avatar image
Former Member

Build UI5 application which agnositic to underline service


I want to create UI5 application which use services from several providers ,

hence I want to create some abstraction layer which is agnostic to the underline services

for example the UI should provide the exact same values but can use different services.

what is the best practice of UI5 in this case ? how it's suggested to create this abstraction layer ? example or reference will be very helpful since Im fairly new to UI5


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Feb 01, 2018 at 08:43 AM

    Hi All,

    Any idea? direction ?


    Add comment
    10|10000 characters needed characters exceeded

  • Feb 23, 2018 at 07:00 AM

    My approach is as follows.

    Its common practice to have a models.js file. This, for example, is often used to create the device model.

    In this file I create my service model that includes all urls that I will need - you can vary this depending on the environment your are deploying to (will ignore that complexity).

    In the models.js file I would, as an example, include these service urls:

     createEnvironmentModel: function(environment, source){
    var data = {
     urls: {
     functions: "https://****api************.net/",
     logging: "https://crosscutting.********/",
     identity: "https://identity.********/",
     proto: "http://localhost:57109/"
     }, ...
    var cModel = new JSONModel(data);

    Consequently this model is accessible from the application as a whole (a global model if you like) given that the above is called from within the Component.js (again as is common practice)

    ], function (UIComponent, JSONModel, models) {
        "use strict";
        return UIComponent.extend("blt.ui5.Component", {
            metadata: {
                manifest: "json"
            init: function () {
                var sEnvironment = "/qac";
                this.setModel(models.createEnvironmentModel(sEnvironment, this), "current");  // <------ named model
                // set the device model
                this.setModel(models.createDeviceModel(), "device");

    I then use this in my service calls (split across a query service (for READ activity) and a command service (for CrUD activity (WRITE))

    An example below:

        getAssetByVin: function (session, vin) {
            return simpleGet(session.urls.functions + "/v1/asset?primaryIdentifier=" + vin, session);

    Where session is effectively the named model (current)

    I hope that makes sense - ask further if you need more direction.

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 22, 2018 at 03:48 PM

    Any service REST complaint can be invoked from the UI5 layer. Bundle service call in a separate JS file, which would act a service layer.

    Then, load the results of service in local JSON models.

    These JSON models can be used in controller or view.



    Add comment
    10|10000 characters needed characters exceeded