Skip to Content
0
Jan 24, 2019 at 05:24 AM

unable to create a view from a string using sap.ui.core.mvc.XMLView.create

361 Views Last edit Jan 24, 2019 at 05:26 AM 2 rev

Hi Experts,

i'm facing some trouble in creating an xml view(using web ide to create fiori app) from a string that holds the data for the view. its hardcoded for now but in future will be returned from a service.

sap.ui.define([
	"sap/ui/core/mvc/Controller",
	"sap/ui/core/mvc/XMLView"
], function (Controller, XMLView) {
	"use strict";


	return Controller.extend("com.sampleapp.SampleApp.controller.View1", {
		onInit: function () {


			this.dataModel = new sap.ui.model.json.JSONModel();


			this.viewString = "<mvc:View xmlns:mvc='sap.ui.core.mvc' xmlns:m='sap.m' controllerName='com.sampleapp.SampleApp.controller.View2'>" +
			"<Page title='dummytitle'><content><m:Label text='Rocky'/></content></Page></mvc:View>";


XMLView.create({
		definition: this.viewString,
		/*controller: new sap.ui.core.mvc.Controller({sName:"com.sampleapp.SampleApp.controller.View2"})*/}).then(function (oView) {
						//	oView.placeAt("content");
					});


}

	});
});

even if I uncomment the controller name then too the error is the same. the promise seems to fail everytime and i cant understand why the issue is present(fyi: the controller already exists in the file system for which the path is provided).

the error I have is:

any help is appreciated.

Thank you.

Attachments

image-1.png (26.3 kB)