I'm trying to refactor the legacy UI5-codebase and would like to use reusable dialogs.
My steps:
- I've downloaded the Walkthrough Step 19: Reuse Dialogs sample
- I've added
HelloDialog.js
into project's./controller/
folder - I've added
HelloDialog.fragment.xml
into project's./view/
folder - I've adjusted a namespace inside of
HelloDialog.js
andHelloDialog.fragment.xml
fromsap.ui.demo.walkthrough.controller.HelloDialog
towebapp.controller.HelloDialog
- I've added a button for the
HelloDialog
to the view:
<Button id = "helloDialogButton"
icon = "sap-icon://world"
text = "Show Popup"
press = ".onOpenDialog" />
- I've added to
App.controller.js
:
onOpenDialog() {
this.getOwnerComponent().openHelloDialog();
},
- I've added
"./controller/HelloDialog"
toComponent.js
and initialize the object:
init(...args) {
UIComponent.prototype.init.apply(this, args);
this.getRouter().initialize();
this._helloDialog = new HelloDialog(this.getRootControl());
}
- I've added hooks to the
exit
andopenHelloDialog
events toComponent.js
:
exit() {
this._helloDialog.destroy();
delete this._helloDialog;
},
openHelloDialog() {
this._helloDialog.open();
},
Now, I run the project and get the a blank page, in DevTools console I see the following error:
Failed to load component for container
rootComponentContainer
. Reason: TypeError:HelloDialog
is not a constructor
The only difference I can spot is that I'm using arrow functions in my code, but can it be that arrow functions break UI5? Perhaps, some issues with the object context.