cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 index.html error

dirk_wieczorek
Participant
0 Kudos

I have the following code in the index.html of an SAPUI5 Develpment Project.
When i test it i get the error :

Uncaught TypeError: sap.ui.getCore is not a function

Can someone give me an advice whats wrong here?
I know it doesnt know the sap.ui bibliothek but its defined and loaded under src.

Regards

Dirk


<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<script id="sap-ui-bootstrap" src="https://sapui5.hana.ondemand.com/1.42.6/resources/sap-ui-core.js" data-sap-ui-libs="sap.m"
data-sap-ui-theme="sap_belize"
data-sap-ui-compatVersion="edge"
data-sap-ui-resourceroots='{"/t4/WebContent/"}'>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script> $(function ()
{ var oCore = sap.ui.getCore();
sap.ui.getCore().attachInit(function () { new sap.m.Shell({ app: new sap.ui.core.ComponentContainer({ name: "t4" }) }).placeAt("content"); }); })
</script> </head> <body role="application"> <div id="content"></div> </body>

Accepted Solutions (1)

Accepted Solutions (1)

dirk_wieczorek
Participant

Thanks for the help. It helped me much to find the solution. The last problem was that i had the wrong resourceroot.
After migrating the code from WebIde to Eclipse one has to change all paths in the project since Eclipse uses another folder structure.
I didn't recognize it first since i don't have much experience in this area. After reading comments here i changed and commented out some lines of code. This provided me some errors in chrome which finally helped me locate the problem. After changing all paths in the Eclipse project and correcting the resourceroot entry my app is now running on the ABAP server too.

Thank you very much for the help.

Regards

Dirk

Answers (2)

Answers (2)

junwu
Active Contributor
0 Kudos

you didn't load the ui5 lib......

dirk_wieczorek
Participant
0 Kudos


Hello Wu,

i forgot to copy the line for the lib here. See comment above. The lib is loaded with the bootstrap


id="sap-ui-bootstrap" src="https://sapui5.hana.ondemand.com/1.42.6/resources/sap-ui-core.js"
data-sap-ui-libs="sap.m"
data-sap-ui-theme="sap_belize"
data-sap-ui-compatVersion="edge" data-sap-ui-resourceroots='{"/t4/WebContent/"}' >lib "sap.m" and the <link rel="stylesheet" type="text/css" href="css/style.css">
<script> $(function () { var oCore = sap.ui.getCore(); sap.ui.getCore().attachInit(function () { new sap.m.Shell({ app: new sap.ui.core.ComponentContainer({ name: "t4" }) }).placeAt("content"); }); })


but when i call sap.ui.getCore() see below it tells me "Uncaught TypeError: sap.ui.getCore is not a function".
The problem derives from the resourceroot entry in the index html. When i define it see appended images then the error occurs. So it seems the resourceroot is wrong but i need it to tell the app where it finds the component.js.

Any advice whats is wrong here?

Regards

Dirk

former_member182862
Active Contributor
0 Kudos

Hi Dirk

Sorry we do not know what you are intending to do. The basic thing works for sure

http://jsbin.com/xuxaraq/edit?html,js,output

Thanks

-D

dirk_wieczorek
Participant
0 Kudos

I have to import a Project that is running in the WebIde into the an SAPUI5 Devlopment project in Eclipse.
In the WebIde the code is running fine but in the Eclipse it doesnt. I try to find out what i have to change so it runs in the eclipse too. I am not familiar with the eclipse but need to solve the problem yesterday........
Through the advice from here i could solve some of the problems and limit it now to
the resourceroot in the project
data-sap-ui-resourceroots='{"/t4/WebContent/"}'

If i take it out the core lib is loaded. But the project is not runing. If i let it in the core lib is not loaded.
But its needed to tell the app where to find its views and controllers.
Project structure:

Any Advice?

Regards

Dirk