Skip to Content

SAPUI5 index.html error

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'/>

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>

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Jul 31, 2017 at 08:18 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 30, 2017 at 08:54 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • Jul 31, 2017 at 05:13 AM

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

    Add comment
    10|10000 characters needed characters exceeded


    • 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