cancel
Showing results for 
Search instead for 
Did you mean: 

Component.js issue with UI5 version 1.26.3

pinakipatra
Contributor
0 Kudos
199

Hi ,

I am using a simple component.js for my ui5 app .

It is running perfectly fine on the versions 1.28 and above .

But the same is throwing errors for version 1.26.3 .

As our netweaver UI5 version is 1.26 we have to use 1.26 version.

Please suggest.

Component JS Code


sap.ui.core.UIComponent.extend("portal.app.Component", {

    metadata: {

        rootView : {

            viewName: ".portal.app.view.Container",

            type: "JS"

        },

        routing: {

              config: {

                routerClass: "sap.m.routing.Router",

                viewType: "JS",

                viewPath: "portal.app.view",

                controlId: "idContainer",

                controlAggregation: "pages"

              },

              routes: [

                {

                  pattern: "",

                  name: "home",

                  viewName: "Home"

                },

                {

                  pattern: "details",

                  name: "details",

                  viewName: "Details"

                }

              ],

        },

    },

    init: function () {

        sap.ui.core.UIComponent.prototype.init.apply(this, arguments);

        this.getRouter().initialize();

    }

});

Below is the error :

at line 34 (sap.ui.core.UIComponent.prototype.init.apply(this, arguments);)

Now if i am using

https://sapui5.hana.ondemand.com/1.26.3/resources/sap-ui-core.js

I am getting the error    but

if i am using

https://sapui5.hana.ondemand.com/1.28.9/resources/sap-ui-core.js

i am not getting any error.

Thanks

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos
  1. sap.ui.core.UIComponent.extend("portal.app.Component", {
  2.     metadata: {
  3.         rootView : {
  4.             viewName: ".portal.app.view.Container",
  5.             type: "JS"
  6.         },
  7.         routing: {
  8.               config: {
  9.                 routerClass: "sap.m.routing.Router",
  10.                 viewType: "JS",
  11.                 viewPath: "portal.app.view",
  12.                 controlId: "idContainer",
  13.                 controlAggregation: "pages"
  14.               },
  15.               routes: [
  16.                 {
  17.                   pattern: "",
  18.                   name: "home",
  19.                   viewName: "Home"
  20.                 },
  21.                 {
  22.                   pattern: "details",
  23.                   name: "details",
  24.                   viewName: "Details"
  25.                 }
  26.               ],
  27.         },
  28.     },
  29. });
  30. portal.app.Component.prototype.init= function () {
  31.         sap.ui.core.UIComponent.prototype.init.apply(this);
  32. jQuery.sap.require("sap.m.routing.RouteMatchedHandler");
  33. var oRouter = this.getRouter();
  34. this.routeHandler = new sap.m.routing.RouteMatchedHandler(oRouter);
  35. oRouter().initialize();
  36.     }
  37. });
pinakipatra
Contributor
0 Kudos

Hi ,

I trhink line number 37 brackets should be removed othervise it gives syntax errors.

Even this is giving the same error.

Former Member
0 Kudos

Hi,

Use debugger to debug the code.. According to me there is no error in Component.js file.. Use debugger in init function and check whether it is being called or not

pinakipatra
Contributor
0 Kudos

Yes init is being called.

actual error is after execution of

sap.ui.core.UIComponent.prototype.init.apply(this)

pinakipatra
Contributor
0 Kudos

as mentioned before it works fine for ui5 version 1.28 and above but for 1.26.3 and below it fails

Former Member
0 Kudos

Hi,

refer this SAPUI5 SDK - Demo Kit

it might help you

Former Member
0 Kudos

Hi Pinaki,

try this

  1. sap.ui.core.UIComponent.extend("portal.app.Component", { 
  2.     metadata: { 
  3.         rootView : { 
  4.             viewName: ".portal.app.view.Container"
  5.             type: "JS" 
  6.         }, 
  7.         routing: { 
  8.               config: { 
  9.                 routerClass: "sap.m.routing.Router"
  10.                 viewType: "JS"
  11.                 viewPath: "portal.app.view"
  12.                 controlId: "idContainer"
  13.                 controlAggregation: "pages" 
  14.               }, 
  15.               routes: [ 
  16.                 { 
  17.                   pattern: ""
  18.                   name: "home"
  19.                   viewName: "Home" 
  20.                 }, 
  21.                 { 
  22.                   pattern: "details"
  23.                   name: "details"
  24.                   viewName: "Details" 
  25.                 } 
  26.               ], 
  27.         }, 
  28.     }, 
  29.    portal.app.Component.prototype.init= function () { 
  30.         sap.ui.core.UIComponent.prototype.init.apply(this);
  31. jQuery.sap.require("sap.m.routing.RouteMatchedHandler");
  32. var oRouter = this.getRouter();
  33. this.routeHandler = new sap.m.routing.RouteMatchedHandler(oRouter);
  34. oRouter().initialize(); 
  35.     } 
  36. });


Thanks,

Sonam

pinakipatra
Contributor
0 Kudos

Hi Sonam ,

Thanks for the reply.

I tried with your code but it is giving syntax error at line 28.

Can you please verify ?

Former Member
0 Kudos

Can you use ";" instead of "," in  28th line

pinakipatra
Contributor
0 Kudos

Hi ,

Still geting error .

pinakipatra
Contributor
0 Kudos