cancel
Showing results for 
Search instead for 
Did you mean: 

Does Web IDE FS functionality to run libraries from workspace only apply to controls?

08-17-2018 8:40 AM
MikeDoyle Active Contributor
1298 views 5 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

I was very excited to read michal.keidar's blog:

https://blogs.sap.com/2018/08/16/how-sap-web-ide-supports-development-of-sap-fiori-reusable-librarie...

I would very much like to run my apps from the workspace with re-use libraries also on the same workspace. I tried this out but it didn't seem to work and I would appreciate some help on why it didn't work. Here's what I did on the main workspace of my trial account (full stack Web IDE):

1) Create Simple UI5 application using template
2) Create library using template
3) In library.js add a type (new version like this: libraryjs.txt)
4) Using context menu on simple UI5 app add reference to the library. For reference manifest.json of simple UI5 app now looks like this:

"dependencies": {
"minUI5Version": "1.30.0",
"libs": {
"sap.ui.layout": {},
"sap.ui.core": {},
"sap.m": {},
"com.md.library": {
"minVersion": "1.0.0"
}
}
},

5) Update Component.js so that the new type is required. Top of Component.js now looks like this:

sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/Device",
"com/md/SimpleUI5/model/models",
"com/md/library/Test"
], function (UIComponent, Device, models, Test) {
"use strict";


6) Add run configuration exactly as per Michal's blog

What I get is this error:

Uncaught Error: failed to load

'com/md/library/Test.js' from ../../resources/com/md/library/Test.js: 404 - Not Found

I can also see a 404 on the network tab with the following url:

https://webidetesting5986836-s0015276274trial.dispatcher.hanatrial.ondemand.com/resources/com/md/lib...

Have I missed something?

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

Hi mike.doyle4,

A type is defined in the library.js file and not in a resources of its own. Since there is no resource there is nothing to load using sap.ui.deifne or jquery.sap.require.

For example see the occurrences of the type CarouselArrowsPlacement in the sap.m library:

The type is set in the library.js and retrieved from anywhere else via the library instance.

So in your case you are missing the definition of the type in your library.js file. Something like this. Wherever you want to load the type in another resource you should do sap.ui.define to the library like here and then you can get it from the library instance like this.

Thanks,

Amiram

MikeDoyle
Active Contributor
0 Likes

Hi Amiram, thanks so much for your help. I did already have a type definition in the library but I see your point about why the reference in the consuming app should be to the library itself. I was thinking of ui.model.FilterOperator and how we use that, but of course that is it's own resource. I've tried using that library reference but to no avail. I just get this message:

ui5loader-dbg.js:1404 Uncaught ReferenceError: Invalid left-hand side in assignment
at eval (<anonymous>)
at execModule (ui5loader-dbg.js:1404)
at requireModule (ui5loader-dbg.js:1293)
at Object.requireSync (ui5loader-dbg.js:1817)
at Object.jQuery.sap.require (jquery.sap.global-dbg.js:1655)
at constructor.t.loadLibrary (Core-dbg.js:1728)
at I.loadLibrary (Interface-dbg.js:44)
at constructor.loadDependencies (Manifest-dbg.js:454)
at constructor.init (Manifest-dbg.js:554)
at U.C.init (ComponentMetadata-dbg.js:183)

As my library is called com.md.library I used the path 'com/md/library/library' but I still get the error. Even when I use "sap/m/library" I get the same error. The define in the Component.js of the consuming app looks like this:

sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/Device",
"com/md/SimpleUI5/model/models",
"sap/m/library"
//"com/md/library/library"
], function (UIComponent, Device, models, library) {
"use strict";

0 Likes

This code in your library.js causes Invalid left-hand side in assignment:

"com.md.library.Test" = {
			Greeting: "Hello"
		}

The double quotes on com.md.library.Test are redundant.


Thanks,

Amiram

MikeDoyle
Active Contributor
0 Likes

Thanks so much Amiram, I've got it working now. I'm planning to get much more used to writing my own libraries....

Answers (1)

Answers (1)

michal_keidar
Advisor
Advisor
0 Likes

amiram.wingarten - Can you please assist?