Suppose I have the following kind of XML:
<core:View xmlns:core="sap.ui.core" ...> <Page> <content> <l:VerticalLayout> <l:content> <core:Fragment fragmentName="my.static.Fragment" type="XML" /> </l:content> </l:VerticalLayout> </content> </Page> </core:View>
The my.Fragment statically loaded. However, now I want to dynamically change the loaded fragment (ideally, using the data binds the fragmentName property, but any other means should also be in order), i.e. something like that:
<core:View xmlns:core="sap.ui.core" ...> <Page> <content> <l:VerticalLayout> <l:content> <core:Fragment fragmentName="{/myDynamicFragment}" type="XML" /> </l:content> </l:VerticalLayout> </content> </Page> </core:View>
However, the latter does not work, and fragment definitions do not allow data binding ... Maybe I missed something, but how should I dynamically change the fragment in my XML representation based on the property of the parameter / model / etc.?
Currently, I resorted to a custom control instead of directly using a fragment in my view, and this control dispatches to the corresponding fragment, but I think it should be simpler, box way ...
source share