Skip to content

Latest commit

 

History

History
33 lines (17 loc) · 1.43 KB

instantiating-fragments-in-declarative-views-234320f.md

File metadata and controls

33 lines (17 loc) · 1.43 KB

Instantiating Fragments in Declarative Views

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

Context

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