Skip to Content
avatar image
Former Member

fragmentName, FragmentDefinition in api

Hi Experts,

I am new to SAP UI5 and trying to explore. I am stuck on a small doubt while working on Fragments. I was following opensap ui5 course and developer guide.

When fragments are created in new XML file, the below is used: -




When the fragments are embedded in XML view declarative, the below construct is used: -

<core:Fragment fragmentName="sample" type="XML">

I am able to get this information from developer guide. But I am unable to locate these 2 "fragmentName" and "FragmentDefinition" from API under sap.ui.core.Fragmentsap.ui.core.Fragment

can you please help me if there is a way to find these in API or correct me if my approach is wrong.

Many thanks


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Dec 19, 2016 at 10:47 AM

    We structure our view files like:

    • businessTypeA
    • businessTypeB
    • fragments
    • App.view.xml

    Within the fragments folder there are subfolders, in case of a bigger application. A view that embeds a fragment we than do:

        <Fragment fragmentName="your.application.namespace.fragments.NameOfToBeIncludedFragment" type="XML" />

    If the fragment is loaded on demand within a controller you can do like:

    if (!this.getView().byId("idOfAControlAtFragment")) {
        this.getView().addDependent(sap.ui.xmlfragment(this.getView().getId(), "your.application.namespace.fragments.NameOfToBeIncludedFragment", this));
    Add comment
    10|10000 characters needed characters exceeded