Friday
Hi, I'm developing a SAPUI5 application and I need to instantiate a fragment (F) within a view (V).
The issue is that the view (V) can be closed by the user. To ensure good performance, I simply destroy it using:
V.destroyDependents();
V.destroyContent();
V.destroy();
However, the user can reopen the same view, which means I need to re-instantiate it, and with it, the fragment. I'm using this code:
Fragment.load({
name: "webapp.fragment.DocumentaleDialog",
id: this.createId("dialogDocumentale"),
controller: this
}).then((oFragment) => {
that.oDocumentaleDialog = oFragment;
that.oView.addDependent(that.oDocumentaleDialog);
openDocumentaleDialog();
});
The problem I'm encountering is a duplicate ID error when I try to instantiate the fragment again.
Request clarification before answering.
anyway you are destroying the view, why not destroy the fragment by your code?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I suggest to avoid destroying it to avoid that error.
openDocumentaleDialog: function () {
if (!this.oDocumentaleDialog) {
Fragment.load({
name: "webapp.fragment.DocumentaleDialog",
id: this.createId("dialogDocumentale"),
controller: this
}).then((oFragment) => {
this.oDocumentaleDialog = oFragment;
this.getView().addDependent(this.oDocumentaleDialog);
this.oDocumentaleDialog.open();
});
} else {
this.oDocumentaleDialog.open();
}
}
Your assumption "To ensure good performance, I simply destroy it" — is partially correct as recreating the fragment from scratch does have a cost. And to be fair, a popup is usually something very minor when it comes to performance and memory overhead.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
25 | |
22 | |
8 | |
8 | |
7 | |
5 | |
4 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.