cancel
Showing results for 
Search instead for 
Did you mean: 

oData sapui5 example - no data

0 Kudos

Hi,

I created very similar app to this from Building - User Interface Add-On for SAP NetWeaver - SAP Library

in component.js i putted url of oData from Northwind  http://services.odata.org/Northwind/Northwind.svc/ but I am still getting info "no data"

What is the reason of that?


jQuery.sap.declare("ksl.md1.Component");

jQuery.sap.require("ksl.md1.MyRouter");

sap.ui.core.UIComponent.extend("ksl.md1.Component", {

metadata : {

name : "Master detail app",

version : "1.1",

includes : [],

dependencies : {

  libs : ["sap.m", "sap.ui.layout"],

  components : []

},

rootView : "ksl.md1.view.App",

config : {

  resourceBundle : "i18n/messageBundle.properties",

  serviceConfig : {

   serviceURL : "http://services.odata.org/Northwind/Northwind.svc/"

   

  }

},

routing : {

   config : {

    routerClass : ksl.md1.MyRouter,

    viewType : "XML",

    viewPath : "ksl.md1.view",

    targetAggregation : "detailPages",

    clearTarget : false

   },

  routes : [

   {  

    pattern : "",

    name : "main",

    view : "Master",

    targetAggregation : "masterPages",

    targetControl : "idAppControl",

    subroutes : [

           {

                                        pattern : "{product}/:tab:",

                                        name : "detail",

                                        view : "Detail"

                                    }

                                  ]

                  },

                  {

                      name : "catchallMaster",

                      view : "Master",

                      targetAggregation : "masterPages",

                      targetControl : "idAppControl",

                      subroutes : [

                                    {

                                        pattern : ":all*:",

                                        name : "catchallDetail",

                                        view : "NotFound",

                                        transition: "show"

                                    }

                                  ]

                  }

                 ]

    }

},

init : function() {

    sap.ui.core.UIComponent.prototype.init.apply(this, arguments);

    var mConfig = this.getMetadata().getConfig();

    // always use absolute paths relative to our own component

    // (relative paths will fail if running in the Fiori Launchpad)

    var rootPath = jQuery.sap.getModulePath("ksl.md1");

    // set i18n model

    var i18nModel = new sap.ui.model.resource.ResourceModel({

        bundleUrl : [rootPath, mConfig.resourceBundle].join("/")

    });

    this.setModel(i18nModel, "i18n");

// Create and set domain model to the component

    var sServiceUrl = mConfig.serviceConfig.serviceUrl;

   

    var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, true);

   

// var oModel = new sap.ui.model.xml.XMLModel(sServiceUrl)

    this.setModel(oModel);

    // set device model

    var deviceModel = new sap.ui.model.json.JSONModel({

        isTouch : sap.ui.Device.support.touch,

        isNoTouch : !sap.ui.Device.support.touch,

        isPhone : sap.ui.Device.system.phone,

        isNoPhone : !sap.ui.Device.system.phone,

        listMode : sap.ui.Device.system.phone ? "None" : "SingleSelectMaster",

        listItemType : sap.ui.Device.system.phone ? "Active" : "Inactive"

    });

    deviceModel.setDefaultBindingMode("OneWay");

   

    this.setModel(deviceModel, "device");

    this.getRouter().initialize();

},

});

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Krzysztof:

Can you attach the screen shot of the console in F12 developer options of browser, so that we can see that error you are getting.

One issue could be cross-origin not allowed: in that you need to create the destination in HCP and than you need to create the project using the northWind service.

One more issue you need to define the same destination in neo app .json file so that project should know which service it needs to call from the destination.

Thanks

Viplove

0 Kudos

Hi sure,

Former Member
0 Kudos

Hi,

Did you create destination on HCP and also in neoapp.json file

Thanks

Viplove

0 Kudos

I forgot to mention that I am creating app in eclipse

maheshgonda
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi ,

after getting service URL you have to make service calls to backend

var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, true);


oModel .read("/entitysetname", {

  success: mathodToCallOnSuccess,

  error: mathodToCallOnError

  });

// before you set model check how data is coming from back end and bind accordingly to view

//in Component level

this.setModel(oModel);


//to set to core

sap.ui.getCore().setModel( oModel,"somelName");

---------------------------------------------------

correct me if i am wrongly understood your question

0 Kudos

Hi

I added

oModel .read("/entitysetname", {

  success: mathodToCallOnSuccess,

  error: mathodToCallOnError

  });

but now there is nothing to display