Dear experts,
I have to decide how to design my code to use single dialog across different views.
I wrote my dialog as fragment (testfragment.xml) and I'm using SAPUI5 v.1.96.14
The following are some solutions I have explored:
1. Connect custom controller to the fragment
Following this post I tried to link the Dialog with its custom controller:

2. Write custom function inside a custom controller
In my project all views are extended to a BaseController that contains custom functions.
I could put all the custom functions of my dialog inside the BaseController.
3. Create the dialog via javascript instead of fragment
I could create my dialog using javascript with new sap.m.Dialog command inside BaseController.
I prefer to avoid this option because the dialog will be complex.
I am not using nested views because they are not needed with dialog.
Does anyone have any advice or other ideas?
Thanks
Fabio
Request clarification before answering.
It seems like your error is rather related to your fragment itself.. are you able to load it at all?
The benefit of a fragment is its reusability and not needing to define the controller. So generally, every time you call the fragment from anywhere, you can define the controller as "this". All custom functions should then be loaded from the respective controller and can be redefined in other controllers.
if(this.oMsgDialog){
Fragment.load({name:"namespace.fragment.MsgDialog", controller: this})
.then(function(dialog){
this.oMsgDialog = dialog;
this.getView().addDependent(dialog);
dialog.open();
}.bind(this));
}else{this.oMsgDialog.open();
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.