-2

How can I remove a view in SAPUI5 when I visit another route such that when I return back its onInit function call again.

My problem is that I want load different master-details applications in same sap.m.SplitApp object but the problem is that I faced with duplicate id.

So one possibility is that that I destroy the old content, while if I destroy the old content I will get rid of duplicate id, but when I want to visit again the old route it says some elements has been destroyed and can not be used any more.

So one possibility is that to find a way to run the onInit function each time that we visit the routes.

  • Does this answer your question? ["onBeforeRendering" or "onAfterRendering" is not called every time the view is opened](https://stackoverflow.com/questions/55082731/onbeforerendering-or-onafterrendering-is-not-called-every-time-the-view-is-o) – Boghyon Hoffmann Aug 24 '22 at 17:57

2 Answers2

0

You can look into onBeforeShow() method of a view. This lifecycle hook will be called everytime a view is displayed. You can do your operations here. See : https://openui5.hana.ondemand.com/#docs/api/symbols/sap.m.NavContainerChild.html. Let me know if this helps.

Rahul Bhardwaj
  • 2,303
  • 1
  • 17
  • 28
  • I know this method but it is not helpful for my case. I really need to know how is it possible to destroy something related to the route to be able to run the onInit each time. But I don't know what I have to destroy, –  Mar 04 '17 at 06:25
-1

Instead of destroy have you tried sap.m.App.removePage(vPage)? I'm assuming that you want to remove a page from an enclosing container control like an App or SplitApp.

Another solution in such cases is to have a single view with rules for visibility in a JSONModel. And then refresh the model with new rules each time.

Hope it helps.