Adding fragment to part of XML view in SAPUI5

To add a fragment to part of the page in XML view first you need to create the XML Fragment i.e Display.fragment.xml
Then in the parent XML view add the VBox where you want to add the fragment after clicking a button


Create the function that will call the fragment after clicking the button

//To show the fragment
_showFormFragment: function(sFragmentName) {
var oFormFragment = sap.ui.xmlfragment(this.getView().getId(), "omsslist.view." + sFragmentName, this);
var vBox = this.byId('displayFragment');
vBox.destroyItems();
vBox.addItem(oFormFragment);
},

Then inside the button click action add the code

this._showFormFragment("Display");

 

Leave a Comment.