Skip to Content

fragmentName, FragmentDefinition in api

Dec 19, 2016 at 10:00 AM


avatar image
Former Member

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


10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Ulrich Block
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));
Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Ulrich,

Thanks a lot for your answer. My doubt is, is there some way where we can find "fragmentName" in api?




In case you mean an API of the current View/Fragment that references a fragment, I do not think so. The above use cases should be sufficient anyway.