diff --git a/app/webapp/Component.js b/app/webapp/Component.js index 1722a297..45136a9d 100644 --- a/app/webapp/Component.js +++ b/app/webapp/Component.js @@ -13,7 +13,8 @@ sap.ui.define(["sap/ui/core/UIComponent", "z2ui5/model/models","z2ui5/cc/Server" } this.getRouter().initialize(); z2ui5.oRouter = this.getRouter(); - this.setModel(Models.createDeviceModel(), "device"); + z2ui5.oDeviceModel = Models.createDeviceModel(); + this.setModel(z2ui5.oDeviceModel, "device"); z2ui5.oConfig = {}; z2ui5.oConfig.ComponentData = this.getComponentData(); diff --git a/app/webapp/controller/App.controller.js b/app/webapp/controller/App.controller.js index a5330ce2..46ab74b4 100644 --- a/app/webapp/controller/App.controller.js +++ b/app/webapp/controller/App.controller.js @@ -5,7 +5,7 @@ sap.ui.define(["sap/ui/core/mvc/Controller", onInit: async function () { - z2ui5.oModel2 = this.getView().getModel(""); + z2ui5.oOwnerComponent = this.getOwnerComponent(); z2ui5.oConfig.pathname = this.getView().getModel("http").sServiceUrl; if (z2ui5?.checkLocal == true ) { z2ui5.oConfig.pathname = window.location.href; diff --git a/app/webapp/controller/View1.controller.js b/app/webapp/controller/View1.controller.js index 0eac6a04..eac84f1d 100644 --- a/app/webapp/controller/View1.controller.js +++ b/app/webapp/controller/View1.controller.js @@ -346,7 +346,7 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/ BusyIndicator.show(); z2ui5.oBody = {}; if (args[0][3] || z2ui5.oController == this ) { - if (z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL == true ){ + if (z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL){ var oModel = z2ui5.oView.getModel( "http"); }else{ oModel = z2ui5.oView.getModel(); @@ -461,8 +461,8 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/ async displayView(xml, viewModel) { let oview_model = new JSONModel(viewModel); var oModel = oview_model; - if (z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL == true){ - oModel = z2ui5.oModel2; + if (z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL){ + oModel = z2ui5.oOwnerComponent.getModel(z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL); } z2ui5.oView = await XMLView.create({ definition: xml, @@ -478,7 +478,7 @@ sap.ui.define(["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/ } }); z2ui5.oView.setModel(z2ui5.oDeviceModel, "device"); - if (z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL == true){ + if (z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL){ z2ui5.oView.setModel(oview_model, "http"); } this._oApp.removeAllPages(); diff --git a/app/webapp/manifest.json b/app/webapp/manifest.json index 946607e9..eff9ee1f 100644 --- a/app/webapp/manifest.json +++ b/app/webapp/manifest.json @@ -15,7 +15,7 @@ "toolsId": "3a966e20-9635-4c28-8861-d1b66f79f1de" }, "dataSources": { - "mainService": { + "test": { "uri": "/sap/opu/odata/DMO/API_TRAVEL_U_V2/", "type": "OData", "settings": { @@ -83,8 +83,8 @@ } }, "models": { - "": { - "dataSource": "mainService", + "test": { + "dataSource": "test", "preload": true, "settings": {} }, diff --git a/src/01/02/z2ui5_if_core_types.intf.abap b/src/01/02/z2ui5_if_core_types.intf.abap index 2946cf89..70585d37 100644 --- a/src/01/02/z2ui5_if_core_types.intf.abap +++ b/src/01/02/z2ui5_if_core_types.intf.abap @@ -68,7 +68,7 @@ INTERFACE z2ui5_if_core_types BEGIN OF ty_s_next_frontend, BEGIN OF s_view, xml TYPE string, - switchDefaultModel TYPE abap_bool, + switchDefaultModel TYPE string, check_destroy TYPE abap_bool, check_update_model TYPE abap_bool, END OF s_view, diff --git a/src/01/03/z2ui5_cl_app_app_js.clas.abap b/src/01/03/z2ui5_cl_app_app_js.clas.abap index 31c99abb..ba0f7b68 100644 --- a/src/01/03/z2ui5_cl_app_app_js.clas.abap +++ b/src/01/03/z2ui5_cl_app_app_js.clas.abap @@ -25,7 +25,7 @@ CLASS z2ui5_cl_app_app_js IMPLEMENTATION. `` && |\n| && ` onInit: async function () {` && |\n| && `` && |\n| && - ` z2ui5.oModel2 = this.getView().getModel("");` && |\n| && + ` z2ui5.oOwnerComponent = this.getOwnerComponent();` && |\n| && ` z2ui5.oConfig.pathname = this.getView().getModel("http").sServiceUrl;` && |\n| && ` if (z2ui5?.checkLocal == true ) {` && |\n| && ` z2ui5.oConfig.pathname = window.location.href;` && |\n| && diff --git a/src/01/03/z2ui5_cl_app_component_js.clas.abap b/src/01/03/z2ui5_cl_app_component_js.clas.abap index 9edc637c..d4ccb8d7 100644 --- a/src/01/03/z2ui5_cl_app_component_js.clas.abap +++ b/src/01/03/z2ui5_cl_app_component_js.clas.abap @@ -33,7 +33,8 @@ CLASS z2ui5_cl_app_component_js IMPLEMENTATION. ` }` && |\n| && ` this.getRouter().initialize();` && |\n| && ` z2ui5.oRouter = this.getRouter();` && |\n| && - ` this.setModel(Models.createDeviceModel(), "device");` && |\n| && + ` z2ui5.oDeviceModel = Models.createDeviceModel();` && |\n| && + ` this.setModel(z2ui5.oDeviceModel, "device");` && |\n| && `` && |\n| && ` z2ui5.oConfig = {};` && |\n| && ` z2ui5.oConfig.ComponentData = this.getComponentData();` && |\n| && diff --git a/src/01/03/z2ui5_cl_app_manifest_json.clas.abap b/src/01/03/z2ui5_cl_app_manifest_json.clas.abap index 636ddc58..c109cf4e 100644 --- a/src/01/03/z2ui5_cl_app_manifest_json.clas.abap +++ b/src/01/03/z2ui5_cl_app_manifest_json.clas.abap @@ -35,7 +35,7 @@ CLASS z2ui5_cl_app_manifest_json IMPLEMENTATION. ` "toolsId": "3a966e20-9635-4c28-8861-d1b66f79f1de"` && ` },` && ` "dataSources": {` && - ` "mainService": {` && + ` "test": {` && ` "uri": "/sap/opu/odata/DMO/API_TRAVEL_U_V2/",` && ` "type": "OData",` && ` "settings": {` && @@ -103,8 +103,8 @@ CLASS z2ui5_cl_app_manifest_json IMPLEMENTATION. ` }` && ` },` && ` "models": {` && - ` "": {` && - ` "dataSource": "mainService",` && + ` "test": {` && + ` "dataSource": "test",` && ` "preload": true,` && ` "settings": {}` && ` },` && diff --git a/src/01/03/z2ui5_cl_app_view1_js.clas.abap b/src/01/03/z2ui5_cl_app_view1_js.clas.abap index f1eeb88b..1c06deac 100644 --- a/src/01/03/z2ui5_cl_app_view1_js.clas.abap +++ b/src/01/03/z2ui5_cl_app_view1_js.clas.abap @@ -366,7 +366,7 @@ CLASS z2ui5_cl_app_view1_js IMPLEMENTATION. ` BusyIndicator.show();` && |\n| && ` z2ui5.oBody = {};` && |\n| && ` if (args[0][3] || z2ui5.oController == this ) {` && |\n| && - ` if (z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL == true ){` && |\n| && + ` if (z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL){` && |\n| && ` var oModel = z2ui5.oView.getModel( "http");` && |\n| && ` }else{` && |\n| && ` oModel = z2ui5.oView.getModel();` && |\n| && @@ -481,8 +481,8 @@ CLASS z2ui5_cl_app_view1_js IMPLEMENTATION. ` async displayView(xml, viewModel) {` && |\n| && ` let oview_model = new JSONModel(viewModel);` && |\n| && ` var oModel = oview_model;` && |\n| && - ` if (z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL == true){` && |\n| && - ` oModel = z2ui5.oModel2;` && |\n| && + ` if (z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL){` && |\n| && + ` oModel = z2ui5.oOwnerComponent.getModel(z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL);` && |\n| && ` }` && |\n| && ` z2ui5.oView = await XMLView.create({` && |\n| && ` definition: xml,` && |\n| && @@ -498,7 +498,7 @@ CLASS z2ui5_cl_app_view1_js IMPLEMENTATION. ` }` && |\n| && ` });` && |\n| && ` z2ui5.oView.setModel(z2ui5.oDeviceModel, "device");` && |\n| && - ` if (z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL == true){` && |\n| && + ` if (z2ui5.oResponse.PARAMS.S_VIEW?.SWITCHDEFAULTMODEL){` && |\n| && ` z2ui5.oView.setModel(oview_model, "http");` && |\n| && ` }` && |\n| && ` this._oApp.removeAllPages();` && |\n| && diff --git a/src/02/z2ui5_if_client.intf.abap b/src/02/z2ui5_if_client.intf.abap index 60c490c0..d020eff0 100644 --- a/src/02/z2ui5_if_client.intf.abap +++ b/src/02/z2ui5_if_client.intf.abap @@ -32,7 +32,7 @@ INTERFACE z2ui5_if_client METHODS view_display IMPORTING val TYPE clike - switchDefaultModel TYPE abap_bool DEFAULT abap_false. + switchDefaultModel TYPE string OPTIONAL. METHODS view_model_update.