Skip to Content
0
May 30, 2018 at 06:44 AM

ComponentContainer-called app methods called multiple times

137 Views Last edit May 30, 2018 at 09:59 AM 2 rev

Hello experts,

Prerequisite: I have three apps App1, App2 and App3. It is possible to call App1 directly via CrossAppNavigator.toExternal:

var oCrossAppNavigator = sap.ushell.Container.getService("CrossApplicationNavigation");
var hash = (oCrossAppNavigator && oCrossAppNavigator.hrefForExternal({
  target: {
    semanticObject: "apps",
    action: "App1"
    },
    params: {
      "Purreqnr": sItem.Purreqnr
      }
    })) || "";
oCrossAppNavigator.toExternal({
  target: {
    shellHash: hash
    }
  });

or to open it by sap.ui.core.ComponentContainer:

//Edit.controller.js
_onRouteMatched : function (oEvent) {
  oArgs = oEvent.getParameter("arguments");
  oView = this.getView();
  var oPage = oView.byId("page");
  var oCompData = {
    PurchaseRequisition : oArgs.Purreqnr
  };
  if (!jQuery.isEmptyObject(this.editComponent)) {
    this.editComponent.destroy();
    delete this.editComponent;
  }
  if(!jQuery.isEmptyObject(this.editContainer)) {
    this.editContainer.destroy();
    delete this.editContainer;
  }
  oPage.destroyContent();
  try{
    this.editContainer = new sap.ui.core.ComponentContainer("atbComponentContainer",{
      lifecycle: sap.ui.core.ComponentLifecycle.Container });
    oPage.addContent(this.editContainer);
    this.editComponent = sap.ui.getCore().createComponent({
      url: "/sap/bc/ui5_ui5/zapps/zapp1",
      name : "app1",
      componentData: oCompData
    });
    this.editComponent.setContainer(this.editContainer);
    this.editContainer.setComponent(this.editComponent);
  }catch(err){
    //
  }
}

Both variants work correctly, App2 opens App1 through ComponentContainer, App3 navigates to App1 and back.

The problem shows when user opens App1 from App3 several times (for example 5 times). Each time user gets back from App1 to App3 there's single call onExit() of App1 which is correct. Then without refreshing through FLP goes to App2, navigates to Edit view which opens App1 by ComponentContainer.

After user navigates back from Edit view to Home view and then again to Edit view there will be this.editComponent.destroy(); called, so it clears previous instance of App1 and will create a new one. But at the moment of this.editComponent.destroy(); the debugger will stop in onExit() of App1 for 6 times (5 times comes from App3 and 1 from App2). So, somewhere in SAPUI5 cache it stores previously opened instances of app and calls onExit() for them, even though this method was already called.

Then, after each navigation Edit -> Home -> Edit view the number of debugger-stops in onExit() will increase by 1 (for each navigation).

But if I force refresh page (Ctrl+F5) and try to navigate Edit -> Home -> Edit multiple times, onExit() will be called once. Multiple instances occurs only after CrossAppNavigator.toExternal navigation and then sap.ui.core.ComponentContainer.

Is it a bug or some cache shall be cleared?

Edit 1: We have sap.ui.version = 1.44.27

Uploaded libraries versions

Regards,

Yaroslav

Attachments