Skip to Content
0

Unable to run SAPUI5 app with custom control in SAP Fiori Launchpad

Apr 21, 2017 at 09:02 AM

54

avatar image
Former Member

I've a custom control in my app. it run as a web application fine. but when i'm running with sap fiori launchpad it give me error.

the structure of file directory is

If i remove my custom control then i can run my app in launchpad. Do I need to add some settings in my manifest file? What could be the reason for this error.

error1.png (241.8 kB)
error2.png (19.7 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Frank Schuler
Apr 21, 2017 at 10:51 AM
0

Hello Ahmed,

Have you extended a standard Fiori app with your custom control? If this was the case, please have a look at this SCN Community Wiki:

SAP Fiori - Extensibility

Best regards

Frank

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member
/* eslint-env jquery */

/* global ace, sap */
sap.ui.define([
    "sap/ui/core/Control"
], function(Control) {
	"use strict";
	
	$("head").append('<link rel="stylesheet" href="sap/ui/codetools/library.css" />');
	
	Control.extend("sap.ui.codetools.CodeEditor", {
	    // the control API:
	    metadata : {
	        properties : {
	        	mode : {
	        		defaultValue : "javascript",
	        		bindable : true
	        	},
	        	value : {
	        		defaultValue : "",
	        		type : "string",
		        	bindable : true
	        	},
	        	contentValid : {
	        		bindable : true,
	        		type : "boolean",
	        		defaultValue : true
	        	},
	        	enabled : {
	        		bindable : true,
	        		type : "boolean"
	        	}
	        }, 
	        events : {
				change : {
					parameters : {
						value : {type : "string"}
					}
				}
	        }
	    },
	
		init : function () {
		},
		
		render : function (x) {
			this._prototype.render();
		},
		
		/*
		getContentValid : function () {
			return this._editor ? this._editor.getSession().getAnnotations().length < 1 : true;
		},
		
		setContentValid : function () {}, // not supported
		*/
		
		getEnabled : function () {
			if (this._editor) {
				return !this._editor.getReadOnly();
			}
			return (this._tmpEnabledBeforeRendering) ? this._tmpEnabledBeforeRendering : true;
		},
		
		setEnabled : function (value) {
			this.setProperty("enabled", value, true);
			if (this._editor) {
				this._editor.setReadOnly(!value);
			} else {
				this._tmpEnabledBeforeRendering = value;
			}
		},
		
		getValue : function () {
			if (this._editor) {
				return this._editor.getValue();
			}
			return (this._tmpValueBeforeRendering) ? this._tmpValueBeforeRendering : "";
		},
		
		setValue : function (value) {
			var that = this;
			this.setProperty("value", value, true);
			if (this._editor) {
				this._editor.setValue(value);
				this._editor.selection.moveTo(0, 0);
			} else {
				this._tmpValueBeforeRendering = value;
			}
		},
		
		focus : function () {
			$(this.getDomRef()).find("textarea")[0].focus();
		},
		
		setVisible : function (visible) {
			//if (this.getDomRef() !== null) {
			//	$("#"+this.getId()).parent().find("div.CodeMirror").css("display", (visible) ? "" : "none");
			//}
	 	},
	
		onAfterRendering :  function() {
			var that = this;
			var div = $( "#" + this.getId() ).get(0);
			var editor = ace.edit(div);
			editor.setTheme("ace/theme/clouds");
			editor.getSession().setMode("ace/mode/javascript");
			editor.getSession().setMode("ace/mode/" + this.getMode());
			editor.setReadOnly(!this.getEnabled());
			editor.$blockScrolling = Infinity;
			editor.on("change", function (e) {
				// the last parameter prevents the control from being marked as dirty and 
				// therefore re-being re-rendered. this is absolutely necessary.
				// see here: https://jam4.sapjam.com/questions/MVikmAEtAZ4MmUWb8XcVmi
				that.setProperty("value", that._editor.getValue(), /* suppressInvalidate */ true); 
				that.fireEvent("change", {
					value: that._editor.getValue()
				});
			});
			var editSession = editor.getSession(); 
			// update the content valid flag when annotations change
			editSession.on("changeAnnotation", function() {
				that.setProperty("contentValid", editSession.getAnnotations().length < 1, /* suppressInvalidate */ true);
			});
			this._editor = editor;
			delete this._tmpEnabledBeforeRendering;
			delete this._tmpValueBeforeRendering;
		},
		
		renderer : function(oRm, oControl){
			 // write the HTML into the render manager
			 oRm.write("<div");
			 oRm.writeControlData(oControl);
			 oRm.addClass("comSapCodetoolsCodeEditor");
			 oRm.writeClasses();
			 oRm.write(">" + oControl.getValue()); // span element
			 oRm.write("</div>");
		}
	});
});

0
Former Member

I've created component like that, it runs fine if in other applications. the problem is when i'm trying to run it in sap fiori launchpad.

0
Jun Wu Apr 21, 2017 at 01:49 PM
0

https://sapui5.hana.ondemand.com/#docs/guide/be0cf40f61184b358b5faedaec98b2da.html

"resourceRoots": {"sap.ui.codetools": "./sap/ui/codetools/" },

try put that in your manifest.json

Share
10 |10000 characters needed characters left characters exceeded