Skip to content

Latest commit

 

History

History
39 lines (22 loc) · 1.7 KB

Instantiating_Fragments_in_Declarative_Views_234320f.md

File metadata and controls

39 lines (22 loc) · 1.7 KB
loio
234320f8d8ee45b39c60893116d60351

Instantiating Fragments in Declarative Views

Example how both types of fragments can be instantiated in an XML view.


In XML views, fragments are used like regular controls, or more precisely, like views.

The following code example shows an XML view that includes both types of fragments, that is an XML fragment and a JS fragment. Each type is instantiated once without a given ID and once with a given ID. These fragment references basically work like import statements including the fragment content controls.

<mvc:View xmlns:mvc="sap.ui.core.mvc" xmlns:core="sap.ui.core" controllerName="testdata.fragments.XMLViewController" >
    
    <core:Fragment               fragmentName="my.useful.SimpleUiPart" type="XML" />
    <core:Fragment id="xmlInXml" fragmentName="my.useful.SimpleUiPart" type="XML" />
    
    <core:Fragment              fragmentName="my.useful.UiPartX" type="JS" />
    <core:Fragment id="jsInXml" fragmentName="my.useful.UiPartX" type="JS" />

</mvc:View>

Related Information

Unique IDs

Using Other Objects Instead of Controllers