Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

It does not work sap.ui.jsfragment.

Hi! (Sorry for the previous post)

I can not use 'jsfragment'. I do not understand why. I'm trying to do everything as follows:

I have a basic view (xml). It posted an internal view ...

FormGoals.view.js


...

<mvc:XMLView viewName="sap.ui.x5.forms.view.MonoTable_Main" id="mono_table_main" async="false"></mvc:XMLView>

...

This is an additional view (xml). In it, I'm trying to build fragment (js):

MonoTable_Main.view.xml

<mvc:View

  height="100%"

  controllerName="sap.ui.x5.forms.controller.MonoTable"

  xmlns:mvc="sap.ui.core.mvc"

  xmlns:l="sap.ui.layout"

  xmlns="sap.m">

  <l:VerticalLayout

     id="MonoTable_Main_Content"

     class="sapUiSmallMargin" >

     <l:content>

         <Text text="Вертикальная область..." />

     </l:content>

  </l:VerticalLayout>

</mvc:View>

MonoTable_Edit.fragment.js

sap.ui.jsfragment("sap.ui.x5.forms.view.MonoTable_Edit", {

  createContent: function(oController){

  var oText = new sap.m.Text({

  text: "Hello World!!!"

  });

  return oText;

  }

});

This controller is an additional view:

FormGoals.controller.js

sap.ui.define([

  'jquery.sap.global',

  'sap/m/MessageToast',

  'sap/ui/core/Fragment',

  'sap/ui/core/mvc/Controller',

  'sap/ui/model/json/JSONModel'

], function(jQuery, MessageToast, Fragment, Controller, JSONModel) {

  "use strict";

  var FormGoalsController = Controller.extend("sap.ui.x5.forms.controller.FormGoals", {

  onInit: function (oEvent) {

  this._showViewFragment("MonoTable_Edit");

  },

  

  _formFragments: {},

  

  _getFormFragment: function (sFragmentName) {

  var oFormFragment = this._formFragments[sFragmentName];

  f (oFormFragment) {

  return oFormFragment;

  }

  oFormFragment = sap.ui.jsfragment(this.getView().getId(), "sap.ui.x5.forms.view." + sFragmentName);

  return this._formFragments[sFragmentName] = oFormFragment;

  },

  

  _showViewFragment: function(sFragmentName) {

  var oLayout = this.getView().byId("MonoTable_Main_Content");

  

  oLayout.removeAllContent();

  oLayout.insertContent(this._getFormFragment(sFragmentName));

  }

  

  });

  return FormGoalsController;

});

If you use the view XML, everything works, but I need it JS.

Tell me, please, what am I doing wrong?

Tags:

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question