cancel
Showing results for 
Search instead for 
Did you mean: 

How can i force localResource's path onto my sapui5 Application

mayadi
Explorer
0 Kudos
4,069

I have been developing an application running sapui5 which doesn't go out of the ordinary.

The bizzare behaviour i have been observing is that my application isn't responding on the localResource i have set for it as it keeps trying to search for the external resource on the online sapui5 library, i have tried different versions of sapui5 library and openui5

here is the index.html:

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<title>Project</title>
<!-- https://openui5.hana.ondemand.com/1.38.21/resources/sap-ui-core.js -->
<script id="sap-ui-bootstrap"
src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js"
data-sap-ui-libs="sap.m"
data-sap-ui-xx-bindingSyntax="complex"
data-sap-ui-theme="sap_bluecrystal">
</script>
<script>
sap.ui.localResources("Project");
var app = new sap.m.App({initialPage:"master"});
var page = sap.ui.view({id:"master", viewName:"Project.master", type:sap.ui.core.mvc.ViewType.XML});
app.addPage(page);
app.placeAt("content");
</script>
</head>
<body id="content">
</body>
</html>

and the Error codes i have been getting

jquery-dbg.js:9203 Failed to load https://openui5.hana.ondemand.com/resources/Project/master.view.xml: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8080' is therefore not allowed access. The response had HTTP status code 404.

Uncaught Error: resource Project/master.view.xml could not be loaded from https://openui5.hana.ondemand.com/resources/Project/master.view.xml. Check for 'file not found' or parse errors. Reason: NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'https://openui5.hana.ondemand.com/resources/Project/master.view.xml'.

the application keeps setting his default resource path as sapui5 library + path to resources instead of 127.0.0.1 + path to resource

I have had no success in using jQuery.sap.registerModulePath aswell with "final" set on true

Accepted Solutions (1)

Accepted Solutions (1)

mayadi
Explorer
0 Kudos

Ok so it seems that i have just made a mistake in naming the root path of my localResources and the one that is used for the view itself, which lead to a url that wasn't usable for sapui5 as it couldn't find the root resource folder. Sapui5 tried to resort to the other url as a fail safe function.

Answers (2)

Answers (2)

CristianBabei
Contributor
0 Kudos

Do you have the neo-app.json?

there is the configuration of the resources :

{
	"routes": [{
		"path": "/webapp/resources",
		"target": {
			"type": "service",
			"name": "sapui5",
			"entryPath": "/resources"
		},
		"description": "SAPUI5 Resources"
	}, {
		"path": "/resources",
		"target": {
			"type": "service",
			"name": "sapui5",
			"entryPath": "/resources"
		},
		"description": "SAPUI5 Resources"
	}, {
		"path": "/sap/opu/odata",
		"target": {
			"type": "destination",
			"name": "TEST",
			"entryPath": "/sap/opu/odata"
		},
		"description": "Destination Cockpit"
	}, {
		"path": "/sap/bc/ui5_ui5",
		"target": {
			"type": "destination",
			"name": "TEST",
			"entryPath": "/sap/bc/ui5_ui5"
		},
		"description": "Destination Cockpit"
	}]
}

Also, when I have to use external UI5 libraries I use this :

src="https://sapui5.hana.ondemand.com/1.50.12/resources/sap-ui-core.js"

Or the local:

src="/resources/sap-ui-core.js"

Dunno if this helps you, hope so.

Regards

mayadi
Explorer
0 Kudos

Hi Cristian,

I will have to look up the neo-app.json as I haven't had the need to use one in all my previous projects,

I will try to use a local library and get back to you to let you know if it worked.

Regards

irfan_gokak
Contributor
0 Kudos

Hi Mehdi,

You're using which IDE? WebIDE or Eclipse?

mayadi
Explorer
0 Kudos

Hi Irfan,

I am using Eclipse Oxygen EE

Regards,