cancel
Showing results for 
Search instead for 
Did you mean: 

how to set view Id ???

Former Member
0 Kudos

Hello everyone,

I am working on a project in which I am using component.js and routing for navigating between views my project consist of no of views which I have defined in one view App.view.js below is the code of app.view.js


createContent: function (oController) {

  // to avoid scroll bars on desktop the root view must be set to block display

  this.setDisplayBlock(true);

  // create app

  this.app = new sap.m.App("App");

// this.app.setBackgroundImage("images/bg2.jpg");

  var launchpad = sap.ui.xmlview("launchpad", "sap.ui.KOL.view.launchpad");

  launchpad.getController().nav = this.getController();

  this.app.addPage(launchpad);

//

  var allKOL = sap.ui.xmlview("allKOL", "sap.ui.KOL.view.allKOL");

  allKOL.getController().nav = this.getController();

  this.app.addPage(allKOL);

as you can see I have given ids to the view launchpad and all kol but when I am running the application the ids are getting initialized automatically as __xmlview00 and is not taking as what I have assigned in the app.view.js .

So can anyone please help me with assigning the ids to the view.

Thanks in advance

Anshul Dharmadhikari

Accepted Solutions (0)

Answers (2)

Answers (2)

bpawanchand
Active Contributor
0 Kudos

Hi,

  That is the standard behavior of creating unique Ids. It is clearly stated even in the sdk help that when ever you set and ID it is either prefixed with view Id

SAPUI5 SDK - Demo Kit

SAPUI5 SDK - Demo Kit

may be you can try using createId() method.

Regards

Pavan

kai2015
Contributor
0 Kudos

As far as I know, you can't set ID to xml view.

Former Member
0 Kudos

Hi Kai ,

by setting the id I mean creating the id for the xmlview cause there is one method creteId for xmlview so do you have any idea how we can use this method .

Thanks,

Anshul D

Former Member
0 Kudos

Hi Generally we set views if from component.js like as shown below.

jQuery.sap.declare("xxx.Component");

sap.ui.core.UIComponent.extend("xxx.Component", {

    createContent : function() {

             // create root view

        var oView = sap.ui.view({

        id : "ViewAppId",

        viewName : "xxx.view.viewName",

            type : "XML",

            viewData : { component : this }

        });

id:  sets the id for the XML View.

Regards,

Koti Reddy

Former Member
0 Kudos

Hi Koti Reddy,

This I have written for the parent app App.view.js but the problem is coming with the child apps of this App.view.js as you can see I have shared the code for App.view.js I have given the id for launchpad as launchpad but its not taking this id instead application is giving the default id __xmlview0

it would be great if you can help me with this issue.

Thanks

Anshul dharmadhikari

kai2015
Contributor
0 Kudos

Hi Anshul,

I still think there is no way to give a XML View an ID.

Why don't you create your App like the Best Practices from the Developer Guide.

SAPUI5 SDK - Demo Kit

There you don't need an XML View ID for navigation.

Former Member
0 Kudos

I think you set the view id's correctly but you might have missed

return this.app;

If already above syntax exist , use below and play .

this.app.addPage(launchpad,false); 

this.app.addPage(allKOL,true);

I am able to use similar to your approach already. If still it won't work , you should check app.controller code which may be creating trouble .

Regards,

Koti Reddy