Skip to Content
author's profile photo Former Member
Former Member

SAPUI5 Application Best Practises with Javascript Views


I have followed the tutorial for the sapui5 "application best practises" that can be found in the following developer guide:

I was able to complete the tutorial without any problems.

Now I decided to do it again using javascript views, but two problems appeared.

I'm at the end of "Step 7: Model View Controller " at page 137 and encountered the following problems:

The "rootView" found in the component code forces me to use a XML view, can't we use a javascript view here?

This is where the path of the"App" view, containing the "splitApp" declaration, is placed.

In my code i have something like rootView : "tdg.view.App", and if i have an App.view.js it will always request for an App.view.xml, even if i force the path to be rootView : "tdg.view.App.view.js", .

tdg: project name

view: folder inside the WebContent, containing the views files

For the sake of trying to continue the project i went with the xml App view and used the code presented in the guide.

As told before, i want my views to be javascript so, the only place i found that needed to be changed was the following code in the Component.js:

routing : {

config : {

routerClass : tdg.MyRouter,

viewType : "JS",

viewPath : "tdg.view",

targetAggregation : "detailPages",

clearTarget : false


Where before in the "viewType" was "XML", now I've changed it to "JS".

I have then created my Master.view.js and Master.controller.js files inside the view folder and tried to run the application with Google Chrome where it showed me an empty background just with the blue color and the following error appeared in the console:

Uncaught TypeError: undefined is not a function UIComponent.js:6

And, running the application with Mozilla Firefox I get this error in the console:

TypeError: t.createContent is not a function sap-ui-core.js line 80 > eval:6:1181

The error appears to be occurring in the line "this.getRouter().initialize();" that is in the init function of the Component.js. If I remove it, then it lets me see the core structure of the SplitApp.

What is causing this error?

(I'm using Luna Eclipse in Windows 8)

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Jan 27, 2015 at 11:43 AM

    Hi Filipe, I don't think you should mix the XML and JS views. If you have started a new project with JS views then it is ok. I would think your issue would be the path. Make sure you are following the correct folder/subfolder/file path. I have encountered this errors because I didn't specify the correct path. the path is relative to where you are referencing your views from. Start with having only one file then fix the rest. Keep in mind that the path to the view and controller is kept in a couple places: 1) inside the view you make a reference to the controller. inside the controller you keep the controller id (which is pretty much its path)

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.