Unable to load library
js1972 opened this issue · 2 comments
Have you managed to get this library to work on HANA XS or anywhere other than on a local machine? I've getting all sorts of errors in trying to load the library from a UI5 page in HANA XS similar to issue #2.
Also - I notice that you have copied the UI5 library into your library? Is there a reason for that? Will it not work without it - don't want to have to double-up on the files...
Any ideas? Note that I added resource-roots to the UI5 bootstrap tag, without that the load library call failed.
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="UTF-8">
<title>test</title>
<script id="sap-ui-bootstrap"
src="/sap/ui5/1/resources/sap-ui-core.js"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-libs="sap.m"
data-sap-ui-xx-bindingSyntax="complex"
data-sap-ui-resourceroots='{
"googlemaps": "googlemaps"
}'>
</script>
<!-- XML-based view definition -->
<script id="view1" type="sapui5/xmlview">
<mvc:View
controllerName="local.controller"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
xmlns:gmaps="googlemaps">
<gmaps:Map height="250px" zoom="12" lat="-33.895" lng="151.275">
<gmaps:markers>
<gmaps:Marker lat="-33.895" lng="151.275" info="Bondi Beach" />
</gmaps:markers>
</gmaps:Map>
</mvc:View>
</script>
<script>
// Controller definition
sap.ui.controller("local.controller", {
onInit: function(oEvent) {
//var myRootPath = jQuery.sap.getModulePath("googlemaps");
//sap.ui.getCore().loadLibrary("googlemaps", [myRootPath, "googlemaps/"].join("/"));
//sap.ui.getCore().loadLibrary("googlemaps", "googlemaps/");
},
clicked: function(oEvent) {
jQuery.sap.require("sap.ui.commons.MessageBox");
sap.ui.commons.MessageBox.alert("Yep, you clicked the button. Well done!");
}
});
sap.ui.getCore().loadLibrary("googlemaps", "googlemaps");
// Instantiate the View, assign a model and display
var oView = sap.ui.xmlview({
viewContent: jQuery("#view1").html()
});
oView.setModel(new sap.ui.model.json.JSONModel({
name: "value"
}));
oView.placeAt("content");
</script>
</head>
<body class="sapUiBody" role="application" id="content">
</body>
</html>
try
data-sap-ui-resourceroots='{ "openui5.googlemaps": "googlemaps"
Thanks John - that solved the problem. The code inside the library must expect that folder hiearchy / namespace of openui5.googlemaps. The following now works well:
It still can't find the followign two files but I've never played around with creating a library before so this may be normal:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="UTF-8">
<title>test</title>
<script id="sap-ui-bootstrap"
src="/sap/ui5/1/resources/sap-ui-core.js"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-libs="sap.m"
data-sap-ui-xx-bindingSyntax="complex"
data-sap-ui-resourceroots='{
"openui5.googlemaps": "googlemaps"
}'>
</script>
<!-- XML-based view definition -->
<script id="view1" type="sapui5/xmlview">
<mvc:View
controllerName="local.controller"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
xmlns:gmaps="openui5.googlemaps">
<gmaps:Map height="250px" zoom="12" lat="-33.895" lng="151.275">
<gmaps:markers>
<gmaps:Marker lat="-33.895" lng="151.275" info="Bondi Beach" />
</gmaps:markers>
</gmaps:Map>
</mvc:View>
</script>
<script>
// Controller definition
sap.ui.controller("local.controller", {
onInit: function(oEvent) {
},
clicked: function(oEvent) {
jQuery.sap.require("sap.ui.commons.MessageBox");
sap.ui.commons.MessageBox.alert("Yep, you clicked the button. Well done!");
}
});
sap.ui.getCore().loadLibrary("googlemaps", "googlemaps");
// Instantiate the View, assign a model and display
var oView = sap.ui.xmlview({
viewContent: jQuery("#view1").html()
});
oView.setModel(new sap.ui.model.json.JSONModel({
name: "value"
}));
oView.placeAt("content");
</script>
</head>
<body class="sapUiBody" role="application" id="content">
</body>
</html>