An UI5 dialog can be defined directly as a Dialog:
<Dialog
xmlns = "sap.m"
id = "helloDialog"
title = "Hello {/recipient/name}">
<beginButton>
<Button
text = "{i18n>dialogCloseButtonText}"
press = ".onCloseDialog" />
</beginButton>
</Dialog>
Or can be wrapped by a FragmentDefinition:
<core:FragmentDefinition
xmlns:core = "sap.ui.core"
xmlns = "sap.m">
<Dialog
id = "helloDialog"
title = "Hello {/recipient/name}">
<beginButton>
<Button
text = "{i18n>dialogCloseButtonText}"
press = ".onCloseDialog" />
</beginButton>
</Dialog>
</core:FragmentDefinition>
As far as I understand, a FragmentDefinition provides a higher degree of reuse since it doesn't depend on any view's controller but can be initialized with a custom controller using sap.ui.core.Fragment.load():
this._oDialog = await Fragment.load({
controller: fragmentController,
id: oView.getId(),
name: "webapp.view.MyDialog"
});
However, according to the documentation, starting UI5 1.93, the loadFragment() function is available on every controller instance extending sap.ui.core.mvc.Controller and this API has several advantages over the generic sap.ui.core.Fragment.load() function.
If I use a loadFragment(), should I still wrap a Dialog with FragmentDefinition? I've tried both implementations, both of them work and I see a dialog on a view, so what are the benefits of using FragmentDefinition if I still can directly call a Dialog with loadFragment()?