I was very excited to read michal.keidar's blog:
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:
Have I missed something?
Request clarification before answering.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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";
amiram.wingarten - Can you please assist?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 10 | |
| 5 | |
| 5 | |
| 5 | |
| 4 | |
| 2 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.