cancel
Showing results for 
Search instead for 
Did you mean: 

How to run Controller Method every time after rendering XML View ?

former_member197071
Participant
0 Kudos

Hello,

I have 2 pages, Homepage and Splitpage. At Splitpage, I am fetching json from remote server and showing it's data using XML view. Problem is that controller method onInit() executes only once.

So if I go back to Home from Splitpage and navigates inside Splitpage again, it still shows old data. It does not fetches remote JSON data (I wrote that code in onInit() method). I also tested onBeforeRendering() method but it also behaves in the same way.

How to work around this issue ?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ankur ,

Yeah its correct .. onInit() function is to just initialise the stuff. I hope you are using pattern matching routing , if yes than what you can do is attach function to Matched event of router ...

onInit: function () {

var oRouter = this.getRouter();

oRouter.getRoute("<splitApp view name>").attachMatched(this._onRouteMatched, this);

}

_onRouteMatched:function()

{

// here you can load your or fetch your data

}


thanks

Viplove

former_member197071
Participant
0 Kudos

Hello,

Instead of "<splitApp view name>" I have to write route name which I mentioned in manifest.json file.


callme: function(oEvent) {

            console.log("Im inside callme()");

        },

onInit: function(){

            console.log('Started onInit');

            var oRouter = this.getRouter();

            oRouter.getRoute('appsplitpage').attachMatched(this.callme(), this);

       },

Now in Chrome console, it is giving following error:

Started onInit

Im inside callme()

Uncaught TypeError: I.fFunction.call is not a function

Former Member
0 Kudos

Hi Ankur,

you are correct you need to write the route name to check the matched pattern ...

oRouter.getRoute('appsplitpage').attachMatched(this.callme, this);


// remove "()" from callme


callme:function () {


}


thanks

Viplove

former_member197071
Participant
0 Kudos

VIPLOVE,

It has worked, my typo mistake.

Former Member
0 Kudos

Hi Ankur ,

Its good you find your mistake ... but please next time thank the person who helped you ... otherwise might be in near future no one help you

thanks

Viplove

Answers (1)

Answers (1)

former_member197071
Participant
0 Kudos

Thank you so much for your help.