Skip to Content

Function call from other controller with passing information about this.getView()

In my MainController I'd like to call a function from my ManualUploadController by pushing a button

The function call itself is working fine like this:

var oManualUploadController = new ManualUpload();
var backendData = oManualUploadController.onGenerateBackendData();

However, in the "onGenerateBackendData()" method, I retrieve models for example like this:

var oModel = this.getView().getModel('odataDetails');

What's funny is:

The ManualUploadController creates a Dialog with some logic in it and the MainController is the "mainpage" from where the dialog gets opened.

When initially accessing the mainpage and trying to push/execute that funciton, I get the error"Uncaught TypeError: Cannot read property 'getModel' of undefined".

But when the Dialog has already been opened previously, then closed again and then the button on the mainpage gets pushed, the function call works fine without any errors.

Do I have to instantiate the controller somehow or how can I solve this problem?

I really hope, I managed to explain my problem so that you understand it. Please let me know if I should try again!

Thanks!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Dec 12, 2018 at 11:35 AM

    Have you used the addDependent when you create the dialog? That could be a good reason ;)

    Add comment
    10|10000 characters needed characters exceeded