cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

UI5 Components: Component-preload.js

js2
Product and Topic Expert
Product and Topic Expert
0 Likes
17,465

When using Components in UI5 apps I can see a stray GET request each time the application is loaded looking for Component-preload.js in the app directory.

There is a little bit of explanation on preloading in the SDK help (but not much). From what I can gather: library pre-loading is something thats only applicable to the SAP-provided UI5 libraries. Our own code can't execute till the UI5 libraries are loaded anyway

I've tried setting data-sap-ui-preload="async" (sync is the default); but then UI5 won't load. Interestingly if I set sap-ui-preload=auto as a url query string parameter; the app seems to load normally (sync) and there is no stray GET on the Component-preload.js file.

Does anyone have any further information on pre-loading and why there is a GET request on this file and the best way to stop it.

If you also know how to stop all the message bundle GET's that would be interesting to know as well.   😉

View Entire Topic
Jayakrishnan
Active Participant
0 Likes

Hi,

                i am working on the SAPUI5 application. As per my application scenario, i have to consume the sap netweaver service and need to populate the data in master and detail page.i have completed the SAPUI5 exercise (10 exercise). so on top of that i am trying to connect with the oData service.

               i added the real service in Component.js file and mentioned the collection name in the master.view.xml. it is working fine. but i am not able to navigate the selected value in the detail page and i do not know where to mention the second service in the code.

/*master.controller page starts*/

  1. jQuery.sap.require("sap.ui.demo.myFiori.util.Formatter");
  2. jQuery.sap.require("sap.ui.demo.myFiori.util.Grouper");
  3. jQuery.sap.require("sap.ui.core.routing.Router");
  4. jQuery.sap.require("sap.ca.scfld.md.controller.ScfldMasterController");

  1. sap.ui.controller("sap.ui.demo.myFiori.view.Master", {

  oView:null,

  oModel:null,

  onInit : function()

  {

  console.log('onInit of master');

  this.oView = this.getView();

  this.oModel = this.oView.getModel();

  },

  handleListSelect : function(evt)

  {

  console.log('calling handleListSelect item');

  var context = evt.getParameter("listItem").getBindingContext();

  console.log('after seting context');

  var url = "/MyFioriUI5/proxy/sap/opu/odata/sap/ZPR_TRACK_SRV;mo/";

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

  // oView.setModel(oModel);

  console.log('after seting context'+oModel);

  this.nav.to("Detail", context);

  },

  handleListItemPress : function (evt) {

  var context = evt.getSource().getBindingContext();

  this.nav.to("detail", context);

  },

/*master.controller page ends*/

/*detail.controller page starts*/

  1. jQuery.sap.require("sap.ui.demo.myFiori.util.Formatter");
  2. jQuery.sap.require("sap.m.MessageBox");
  3. jQuery.sap.require("sap.m.MessageToast");

  1. jQuery.sap.require("sap.ca.scfld.md.controller.BaseDetailController");

  1. sap.ui.controller("sap.ui.demo.myFiori.view.Detail", {

  

    onBeforeRendering : function() {

    console.log('in detail page');

  

this.byId("SupplierForm").bindElement("BusinessPartner");

          

    },

    handleNavButtonPress : function()

    {

    console.Log('in detail page1');

    }

});

/*detail .controller page ends*/

/*Component.js page starts*/

  1. jQuery.sap.declare("sap.ui.demo.myFiori.Component");
  2. jQuery.sap.require("sap.ca.scfld.md.ComponentBase");

  1. sap.ui.core.UIComponent.extend("sap.ui.demo.myFiori.Component", {

  metadata: sap.ca.scfld.md.ComponentBase.createMetaData(

  "MD", {

  "name" : "Purchase Requisition",

  "version" : "1.0.0",

  "library" : "sap.ui.demo.myFiori",

  "dependencies" : {

  "libs" : [ "sap.m", "sap.me" ],

  "components" : []

  },

  "config" : {

  "resourceBundle" : "i18n/messageBundle.properties",

  "titleResource" : "app.Identity",

  "icon" : "sap-icon://Fiori2/F0402",

  "favIcon" : "./resources/sap/ca/ui/themes/base/img/favicon/Approve_Purchase_Orders.ico",

  "homeScreenIconPhone" : "./resources/sap/ca/ui/themes/base/img/launchicon/Approve_Purchase_Orders/57_iPhone_Desktop_Launch.png",

  "homeScreenIconPhone@2" : "./resources/sap/ca/ui/themes/base/img/launchicon/Approve_Purchase_Orders/114_iPhone-Retina_Web_Clip.png",

  "homeScreenIconTablet" : "./resources/sap/ca/ui/themes/base/img/launchicon/Approve_Purchase_Orders/72_iPad_Desktop_Launch.png",

  "homeScreenIconTablet@2" : "./resources/sap/ca/ui/themes/base/img/launchicon/Approve_Purchase_Orders/144_iPad_Retina_Web_Clip.png"

  },

  masterPageRoutes : {

  "master" : {

  "pattern" : "GET_ALL_PRSet",

  "view" : "sap.ui.demo.myFiori.view.Master"

  }

  },

  detailPageRoutes : {

  "detail" : {

  "pattern" : "GET_PR_DetailsSet/{contextPath}",

  "view" : "sap.ui.demo.myFiori.view.Detail"

  },

  "noData" : {

  "pattern" : "noData",

  "view" : "empty",

  }

  }

  }),

  createContent : function() {

  // create root view

  var oView = sap.ui.view({

  id : "app",

  viewName : "sap.ui.demo.myFiori.view.App",

  type : "JS",

  viewData : {

  component : this

  }

  });

  // Using OData model to connect against a real service

  var url = "/MyFioriUI5/proxy/sap/opu/odata/sap/ZPR_TRACK_SRV;mo/";

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

  oView.setModel(oModel);

  // set i18n model

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

  bundleUrl : "i18n/messageBundle.properties"

  });

  oView.setModel(i18nModel, "i18n");

  // set device model

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

  isPhone : jQuery.device.is.phone,

  isNoPhone : !jQuery.device.is.phone,

  listMode : (jQuery.device.is.phone) ? "None" : "SingleSelectMaster",

  listItemType : (jQuery.device.is.phone) ? "Active" : "Inactive"

  });

  deviceModel.setDefaultBindingMode("OneWay");

  oView.setModel(deviceModel, "device");

  // Using a local model for offline development

// var oModel = new sap.ui.model.json.JSONModel("model/mock.json");

// oView.setModel(oModel);

  // done

  return oView;

  }

});

/*Component .js page ends*/

 

});

Thank you,

Regards,

JK