Skip to Content
0

fragmentName, FragmentDefinition in api

Dec 19, 2016 at 10:00 AM

53

avatar image

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: -

<core:FragementDefinition

xmlns="sap.ui.core">

</core:FragmentDefinition>

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

Harinadh

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
0

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:

<View
    controllerName="your.applications.namespace.controller.businessTypeA.ControllerName"
    xmlns="sap.ui.core">
    <Fragment fragmentName="your.application.namespace.fragments.NameOfToBeIncludedFragment" type="XML" />
</View>

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

Hi Ulrich,

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

Thanks

Harinadh

0

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.

0