ProjectInfo: Application build with Master/Detail Fiori template in WebIDE
I have a list on my detail page where each item should link to a new view in the details part of the application when selected.
Detail.controller.js:
onInspectionSelect : function(oEvent) {
var oBindingContext = oEvent.getParameter(
"listItem").getBindingContext();
this.getEventBus().publish("InspectionDetails", "Context", { context : oBindingContext} );
this.getRouter().myNavToWithoutHash({
currentView : this.getView(),
targetViewName : "DOHMH.view.InspectionDetails",
targetViewType : "XML",
transition : "slide"
}); },
My InspectionDetails.controller.js:
onInit : function() {
var bus = sap.ui.getCore().getEventBus();
bus.subscribe("InspectionDetails", "Context", this._inspection, this);
},
_inspection : function (channelId, eventId, data) {
if (data && data.context) {
this.getView().setBindingContext(data.context);
var sEntityPath = data.context.getPath();
this.bindView(sEntityPath);
}
},
It doesn't work the first time I select a list item from the details page due to the InspectionDetails.controller wasn't subscribed when the select event triggered a publish.
Unfortunately, I have no idea how to architecture it right or how to instantiate the controller in advance to avoid the first call being missed out.
To instantiate the controller within the details controller does not work: jQuery.sap.require("DOHMH.view.InspectionDetails"); (returns 404) because it doesn't know if it's getting the InspectionDetails.view.xml or InspectionDetails.controller.js
Solved- Thanks for all help!
Also found a video solution: https://open.sap.com/courses/fiux1/items/3gZjaL857KYu6MYA06dJEs#66