Skip to Content
1
Aug 12, 2021 at 12:37 AM

Why Do I Get-TypeError: oView is null-UI5 Walkthrough Step 19 Reuse Dialogs?

480 Views

I was going through the UI5 Walkthrough Step 19 - Reuse Dialogs. USing Firefox I get an error:

Uncaught TypeError: oView is null
open HelloDialog.js:29
openHelloDialog Component.js:36
onOpenDialog HelloPanel.controller.js:16

On Chrome:

Uncaught TypeError: Cannot read property 'getId' of null HelloDialog.js:29

Here is the few lines surrounding that section of code:

            if (!this.pDialog) {
                var oFragmentController = {
                    onCloseDialog : function () {
                        oView.byId("helloDialog").close();
                    }
                };
                // load asynchronous XML fragment
                this.pDialog = Fragment.load({
                    id: oView.getId(),
                    name: "sap.ui.demo.walkthrough.view.HelloDialog",
                    controller: oFragmentController
                }).then(function (oDialog) {
                    // connect dialog to the root view of this component (models, lifecycle)
                    oView.addDependent(oDialog);
                    return oDialog;
                });
            }