Showing results for 
Search instead for 
Did you mean: 

Extending a Fiori Elements Object Page to fire a function on every page switch


Hi experts,

I have a CDS view exposed as a Fiori Elements application. I would like to add a custom table to the Object Page screen you navigate to when you click on the line from the List Report. I have successfully done this by creating an Extension, and now I have a view.xml and a controller.js which adds the Facet to the Object Page, and the table is set up in the XML view. These files are in the 'ext' folder in the app folder in WebIDE Full Stack.

My question is how can I add some functionality to the controller to detect every page switch? I want to update the JSONModel with the data for the current line item I'm looking at, in order to populate the custom table.

I have looked at the attachRouteMatched() function of the Router, but this does not fire the first time, and seems to fire on navigation back to the List Report too, which means the Model is updated with the previous item's data, not the current one.

I have tried adding an event delegate of onBeforeShow which is what I use on my normal SAPUI5 apps, but this does not work here. Using onBeforeRendering lifecycle of course only runs the first time the Object Page is navigated to.

Does anyone know how I can fire a function every time the app navigates to the Object Page from the List Report?

Many thanks

View Entire Topic

Once you have created the object page extension, you'll want to add the following code in onInit().

onInit: function () {
    var onPageDataLoaded = function () {
        // Do whatever you want here

    // Attach page data loaded callback of extension API