cancel
Showing results for 
Search instead for 
Did you mean: 

Only Page Title displayed when add content dynamically to the shell in SAPUI5

former_member184238
Participant
0 Kudos

Hi,

I want to display charts one by one in one page without clicking any button.

For that I used Navigation bar to display headings of that charts.

In that I used setInterval function to navigate to another item without clicking on that .Then  I am getting id of that selected Item and navigate to already existing views based on that selected Item using below code in onInit function.

onInit: function(oevent) {

   var oShell = sap.ui.getCore().byId("myShell");

    var length = oShell.mAggregations.worksetItems.length;

    var i = 0;

     var id = setInterval(function() {

      if(i >= length)

      {

      i=0;

      }

      oShell.setSelectedWorksetItem('__item'+i);

      var selectedId = oShell.getSelectedWorksetItem();

       var view = new sap.ui.view({

              viewName : "chart_nav_bar.chart"+i,

               type : "JS"

         });

              oShell.setContent(view);

               i++;

  }, 3000);

  },

My project Structure is like below.

But the Problem is I am not getting any content . I am getting only title of that particular views like below.

In that image I am navigating to chart0.js file. In that  I am having simple button with title chart0. But I am getting only Title without button.

I followed below URL to add the view as content to the Shell dynamically.

http://scn.sap.com/community/developer-center/front-end/blog/2012/10/15/consume-netweaver-gateway-se...

I already applied   this.setHeight("100%"); .Still I am facing same issue.

Please help me to solve this Issue.

Thanks&Regards

Sridevi

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

This message was moderated.

kammaje_cis
Active Contributor
0 Kudos

Can you rerender the shell after adding the view?

after oShell.setContent(view);

add, oShell.rerender();

former_member184238
Participant
0 Kudos

Hi,

Thanks for the reply. Still I am facing same issue.

My Project Structure is like below.

index.html

navbar.view.js

navbar.controller.js

And I have another views like chart0,chart1,chart2,chart3. All those view are having simple data like titile and Button .For example chart0 code is like below.

chart0.view.js

When I run this chart0.view.js file individually then I am getting Button with Title.But when I am adding this to the Shell then I am getting only Title .

I have title names chart0,chart1,chart2,chart3 for the remaining views with dummy content.

I can navigate to every view for every 3000 sec.But in every view I am getting only Title like chart0, chart1,chart2,chart3  but not content .

Please go through that code once and suggest me where I have done mistake.

Thanks&Regards

Sridevi

former_member182650
Contributor
0 Kudos

Hi again,

Try to add content without [] :

new sap.m.Page("char0", {

   title: "Chart0",

   content : button0

  });


Kind regards,

former_member184238
Participant
0 Kudos

Hi,

Thanks for your reply.

still getting same issue.

Thanks&Regards

Sridevi

former_member184238
Participant
0 Kudos

Hi,

I tried all the above solutions to get the charts one by one in Navigation bar with some time Interval without clicking any button.

I can navigate to every view for every 3 seconds. Still I am getting same problem that only page title of every view is displayed without content.

I don't know where I am doing mistake in my code.

Please help.

Thanks&Regards

Sridevi

0 Kudos

Does your content make it into the DOM?

former_member184238
Participant
0 Kudos

Hi,

Thanks for your reply.

I am getting Charts one by one . It's my small mistake in my code.

Regards

Sridevi

former_member184238
Participant
0 Kudos

NO Body

former_member182650
Contributor
0 Kudos

Maybe the problem is that views are already created. Try this code:

onInit: function(oevent) {

    var oShell = sap.ui.getCore().byId("myShell");

    var length = oShell.mAggregations.worksetItems.length;

    var i = 0;

      var id = setInterval(function() {

      if(i >= length) i=0;

        oShell.setSelectedWorksetItem('__item'+i);

      var selectedId = oShell.getSelectedWorksetItem();

  if (sap.ui.getCore().byId("chart_nav_bar.chart"+i) != undefined){

  sap.ui.getCore().byId("chart_nav_bar.chart"+i).destroy();

  var view = sap.ui.view( {

  id : "chart_nav_bar.chart"+i,

  viewName : "view." + viewId, //Assuming your views are saved in view package

  type : sap.ui.core.mvc.ViewType.JS

  });

  oShell.setContent(view);

  } else {

  var view = sap.ui.view( {

  id : "chart_nav_bar.chart"+i,

  viewName : "view." + viewId, //Assuming your views are saved in view package

  type : sap.ui.core.mvc.ViewType.JS

  });

  oShell.setContent(view);

  }

        i++;

  }, 3000);

  },

Kind regards!

former_member184238
Participant
0 Kudos

Hi,

Thank for your reply.

My views are in chart_nav_bar folder.

In that you mentioned viewId, that means view name or id of that view.

Please reply me.

Thanks&Regards

Sridevi

former_member182650
Contributor
0 Kudos

Hi again,

Then replace viewName : "view." + viewId for viewName : "chart_nav_bar." + viewId

Kind regards,

former_member184238
Participant
0 Kudos

Hi,

I am sorry.That's not my quession.

viewName : "view." + viewId,


In above sentence viewId means view name or id of that view.



Below is my  chart0.view.js


sap.ui.jsview("chart_nav_bar.chart0", {

  getControllerName : function() {

  return "chart_nav_bar.chart0";

  },

 

  createContent : function(oController) {

var button0 = new sap.m.Button({

  text : "Sample Button"

  });

  return new sap.m.Page("chart0",{

  title: "Chart0",

  content: [button0]

  });

  }

});

I changed my code like below in navbar.controller.js

if (sap.ui.getCore().byId("chart"+i) != undefined){

      sap.ui.getCore().byId("chart"+i).destroy();

      var view = sap.ui.view( {

       id : "chart_nav_bar.chart"+i,

       viewName : "chart_nav_bar.chart"+i ,

       type : sap.ui.core.mvc.ViewType.JS

       });

       oShell.setContent(view);

      }else{

    

      var view = sap.ui.view( {

       id : "chart_nav_bar.chart"+i,

       viewName : "chart_nav_bar.chart"+i ,

       type : sap.ui.core.mvc.ViewType.JS

       });

       oShell.setContent(view);

      }

My view names are chart0, chart1, chart2. I want to get all these charts in that shell. My shell is in navbar.view.js file.Here, I am getting chart view names dynamically

Still I am facing same issue.I am getting only title chart0 without button. Even when I check the code in developer tools I am getting only title of that page.

If I run that views individually it's working fine and getting button also.When I add that content to the shell then only I am facing this issue. I am in confusion where I have done mistake.

Is there any wrong in my code?

Please help me.

Thanks&Regards

Sridevi


former_member182650
Contributor
0 Kudos

I think your var i always has value 0. Is it possible? Could you post all your html + js code?