cancel
Showing results for 
Search instead for 
Did you mean: 

UI5 + RDE: Javascript view can't be loaded

former_member190457
Contributor
0 Kudos

Hi all,

I've had some UI5 experience over the last months developing Java EE applications with UI5 javascript frontend, deployed to HCP.

Now I'd like to learn the HTML5 side of HCP, in order to develop UI5 applications, leveraging also RDE.

However, with RDE/HTML5, I'm really unable to load a very easy application ("hello world") which shows a simple textview controller in the main Javascript view.

I can see that the RDE wizard creates a XML view, which I deleted and changed the UI5 application to be fully javascript oriented with a JS view.

Of course I also edited the index.html accordingly.

Whatever I do, I get a weird javascript error:

  1. Uncaught TypeError: undefined is not a function JSView.js:6
    1. (anonymous function)JSView.js:6
    2. d.runWithPreprocessorssap-ui-core.js:134
    3. sap.ui.core.mvc.JSView.onControllerConnectedJSView.js:6
    4. sap.ui.core.mvc.View._initCompositeSupportView.js:6
    5. E.extend.constructorsap-ui-core.js:134
    6. M.extend.constructorsap-ui-core.js:134
    7. E.extend.constructorsap-ui-core.js:134
    8. fsap-ui-core.js:122
    9. fsap-ui-core.js:122
    10. osap-ui-core.js:116
    11. sap.ui.viewView.js:6
    12. o.(anonymous function)sap-ui-core.js:116
    13. (anonymous function)index.html?hc_orionpath=%2Fi044892trial%24I044892-OrionContent%2Fportaltest&sap-ui-language=en&sap-…...

The Chrome debugger doesn't even get into the view code itself, the error is at framework level.

I am starting to wonder whether there's any requirement/limitation on how the HTML5 applications should be arranged (e.g. only UI5 XML views are supported).

Could anyone please shed some light?

Thanks a lot

Regards

Vincenzo

Tags edited by: Michael Appleby

Accepted Solutions (1)

Accepted Solutions (1)

shankar_gomare
Explorer
0 Kudos

Hi  Vincenzo,

Based on the error message it looks like your JSview is not loaded properly. here is example..


<script>

sap.ui.localResources("treetable");

var view = sap.ui.view({id:"idtabletree1", viewName:"treetable.tabletree", type:sap.ui.core.mvc.ViewType.JS});

view.placeAt("content");

</script>

Regards,

Shankar

former_member190457
Contributor
0 Kudos

Hi Shankar,

thanks for your reply

My code in index.html seems ok as it is actually like


<script>

sap.ui.localResources("view");

var view = sap.ui.view({id:"jsview", viewName:"view.jsview", type:sap.ui.core.mvc.ViewType.JS});

view.placeAt("content");

</script>

The folder structure is:

the ui5 destinations seem ok in the neo-app.json

Still I get the error above.

Are you sure that js views are supported?

Thanks a lot, regards

Vincenzo

Margot
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Vincenzo,

I just tested it myself and actually did not have any issue.

Not sure which template you used. I started with the empty SAPUI5 mobile app. Then created a new file naming it jsview.view.js and added some coding there:


sap.ui.jsview("view.jsview", {


getControllerName : function() {
  return "view.jsview";
},


createContent : function(oController) {
   return new sap.m.Page({
   title: "Title",
   content: [
   
   ]
  });
}

});

And changed the view type from sap.ui.core.mvc.ViewType.XML to sap.ui.core.mvc.ViewType.js in the index.hmtl


  <script>

    sap.ui.localResources("view");

    var app = new sap.m.App({initialPage:"jsview"});

    var page = sap.ui.view({id:"jsview", viewName:"view.jsview", type:sap.ui.core.mvc.ViewType.JS});

    app.addPage(page);

    app.placeAt("content");

  </script>

All worked fine ...

Regards, Margot

former_member190457
Contributor
0 Kudos

Right, I got it working thanks a lot Margot.

The problem was related to the ID of the view in the constructor not correctly specified.

Now it's working fine, also without the sap.m.App container

Regards

Vincenzo

Answers (0)