Hello Experts,
I develop a SAP FIORI Custom Application, this is working fine without any issue when we run it directly by its URL.
But problem is that when I am running it by FIORI Launch Pad I am getting the following error (still functionality working fine) when navigate from one view to another.
And getting following errors in Console –
2015-10-26 11:11:31 Illegal new hash - cannot be parsed: 'page|{"id":"Detail"}|0' - sap.ushell.renderers.fiori2.Shell.controller core-min-0.js:85
core-min-0.js:85 2015-10-26 11:11:31 Could not open app. Try again later. - core-min-0.js:85
I am using getEventBus() Method for navigation so the bus subscription code is in App.view.Controller as following.
onInit: function() {
var bus = sap.ui.getCore().getEventBus();
bus.subscribe("nav", "to", this.navHandler, this);
},
navHandler : function(channelId, eventId, data) {
if (eventId === "to") {
if (!data.id) {
jQuery.sap.log
.error("'nav to' event cannot be processed. data.id must be given");
}
this.navTo(data.id, data.data, true);
} elseif (eventId === "back") {
if (!data.step) {
data.step = 1;
}
if (data.home) {
jQuery.sap.history.backToHash("");
} elseif (data.step > 0) {
jQuery.sap.history.back(data.step);
} else {
jQuery.sap.log
.error("'nav back' event cannot be processed. At least one from [data.step, data.home] must be given with valid value");
}
} elseif (eventId === "virtual") {
jQuery.sap.history.addVirtualHistory();
} else {
jQuery.sap.log
.error("'nav' event cannot be processed. There's no handler registered for event with id: "
+ eventId);
}
},
navTo : function(id, data, writeHistory) {
if (id === undefined) {
// invalid id
jQuery.sap.log
.error("navTo failed due to missing id");
} else {
// load view on demand
var app = this.getView().app;
if (app.getPage(id) === null) {
var type = ("Home" === id) ? "JS" : "XML";
var page = sap.ui.view({
id : id,
viewName : "com.abc.view." + id,
type : type
});
app.addPage(page);
jQuery.sap.log
.info("app controller > loaded page: "
+ id);
}
// navigate in the app control
var transition = ("Update" === id) ? "show"
: "slide";
app.to(id, transition, data);
// write browser history
if (writeHistory === undefined || writeHistory) {
var bookmarkable = false;
var stateData = {
id : id
};
jQuery.sap.history.addHistory("page",
stateData, bookmarkable);
}
// log
jQuery.sap.log.info("navTo - to page: " + id);
}
},
And navigation code from one to other is as below –
handleListItemPress : function (evt) {
var cust_no = evt.getSource().mProperties.title;
var cust_name = evt.getSource().mAggregations.attributes[0].mProperties.text;
var cust_city = evt.getSource().mAggregations.attributes[1].mProperties.text;
var bus = sap.ui.getCore().getEventBus();
bus.publish("nav", "to", {
id : "Detail",
data : {
cust_no : cust_no,
cust_name : cust_name,
cust_city : cust_city
}
}), sap.ui.getCore().getEventBus().publish("app", "RefreshDetail", {
context : evt.getSource().getBindingContext(),
cust_no : cust_no,
cust_name : cust_name,
cust_city : cust_city
});
},
I don’t know where I am wrong, if you find any solution for it please help me.
Thanks & Regards,
Imran Ali