Skip to Content

Help defining a controller in Component.js

So I am following this tutorial, where all has gone well until I hit step 19.

I am following it along from within HANA Studio not the Web IDE and I have made one change in declaring the root directory.

The tutorial suggested (in step 4):
data-sap-ui-resourceroots='{ "sap.ui.demo.wt": "./" }'

I declared it as:
data-sap-ui-resourceroots='{"xsapp": "/xxxx/0RPO/XSAPPS/CD126_test/"}'

So now we have that out of the way, I believe my problem relates to how I am defining the Dialog within Controller.js. In the tutorial it starts like this:

sap.ui.define([
	"sap/ui/core/UIComponent",
	"sap/ui/model/json/JSONModel",
	"sap/ui/demo/wt/controller/HelloDialog"

], function (UIComponent, JSONModel, HelloDialog) {......}

My guess, is that my problem comes from line 4 above but I cannot workout what the full path refers to. I mean I know what the target is but this does not resemble my directory path which would be /xxxx/0RPO/XSAPPS/CD126_test/controller/HelloDialog.controller.js. I have also tried defining it with the full URI which looks something like:http://server:port/xxxx/0RPO/XSAPPS/CD126_test/controller/HelloDialog.controller.js and like: xsapp(which refers to the root directory)/controller/HelloDialog.

So what am I doing wrong.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Nov 27, 2017 at 02:51 PM

    Hi,

    This parameter defines root path of your application. Take a look.

    data-sap-ui-resourceroots='{ "sap.ui.demo.wt": "./" }'

    Here your project path starts from sap.ui.demo.wt and to access particular controller you have to define it as

    sap.ui.define(["sap/ui/demo/wt/controller/HelloDialog"

    And in your case you have specified it wrong. It’s exact syntax is.

    data-sap-ui-resourceroots='{ "<any path name>": "./" }'

    “./“ is your root folder of your app.

    Hope it’s clear.

    Add comment
    10|10000 characters needed characters exceeded

    • What you explained was correct, it deals with declaring the root directory in the index.html. Which as I said, I have this sorted, I have made amendments to it but it still works as expected.

      My concern relates to declaring my controllers from the Component.js

      Thanks though for your input.