cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 page View reload issue

Former Member
0 Kudos

Hi Experts,

          I have created an app that has a view that shows graph. The graph will be rendered in a view called CompareEmpChart this VIEW i rendered in

a dialog. so that i call call the same view from multiple places. that means the graph rendering in this CompareEmpChart view inside dialog is

dynamic. so my problem is when use this call this view from any page at  it will work properly but only for the first time. That means second time when

I call the same view it won't open the dialog until I reload the page. I dont know what is the issue...

SECOND TIME MY DIALOG IS NOT GETTING OPENED UNTIL I RELOAD THE VIEW. BUT FROM THE SAME VIEW MY DIALOG WILL OPEN MULTIPLE TIME BUT WHEN I CALL THE SAME VIEW FROM ANY OTHER VIEW IT WON'T OPEN THE DIALOG UNTIL I RELOAD

//////////////// below is my code to open the dialog

var cmpEmpChart = sap.ui.view({viewName:"myApp.uplan.view.CompareEmpChart",type:sap.ui.core.mvc.ViewType.XML});

     

if(typeof dialog === "undefined") {

            dialog = new sap.m.Dialog({

                 id : "idCustomDialog",

                 showHeader:false,

                 contentWidth : Math.round(window.screen.availWidth * 1) +"px" ,

                 contentHeight : Math.round(window.screen.availHeight * 1) +"px",

                 content : cmpEmpChart,

                 endButton: new sap.m.Button({

                     text: 'Close',

                     type:"Reject",

                     press: function () {

                         that.getView().getModel('emp').refresh();

                         compareEmp = { };

                         sap.ui.getCore().byId("lb2").rerender();

                         that.renderItems();

                         dialog.close();

                 }

             }),

            });

            that.getView().addDependent(dialog);

       }

       //dialog.addStyleClass('hideHeader');

       dialog.open();

Accepted Solutions (1)

Accepted Solutions (1)

RameshShrestha
Contributor
0 Kudos

Hi Jithin,

May be there is duplicate id error. You cannot add same view many places unless you destroy it while navigating away.

You can check your console for the error.

If my guess is right, just destroy the view once you try to navigate away.

With Regards,

Ramesh Shrestha

Former Member
0 Kudos

Hi,

so you think the problem is not in dialog it self but in the view? How do i destroy the view or maybe even better question, how do i catch the navigate away action?

Thanks for the help.

Regars, Matevz

RameshShrestha
Contributor
0 Kudos

The problem is while reloading, if the previous content is not destroyed, while trying create new one, it will give duplicate id error as you cannot have 2 UI with same id.

Please just check in debugging mode. This is just my guess for your error. We can confirm once you see it by debugging.

With Regards,

Ramesh Shrestha

Former Member
0 Kudos

I'm not getting the duplicate error id.

As is stated in posts before, you go to a page A and the dialog opens, then you go to the page B (during the same session) and reload the page there, once you go back to page A it won't open the dialog again, no errors no warnings. All the code that is in onInit method executes, including dialog.open().

I tried getting the dialog by id before creating it, but it returns false, which is ok, because the reload (F5 orCTRL+SHIFT+R) of the page should cause that, but i guess it doesn't clear everything.

Also i call dialog.isOpen() before dialog.open() and it returns false, after dialog.open() it returns true. So i guess there must be a rendering problem.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi ,

Use get element by Id to check if the view exist and if so :

cmpEmpChar.destroy();


and then use your code.


the above stand for any other object related to the XML view.


Check your console for "Duplicate ID" error mesages.

jamie_cawley
Advisor
Advisor
0 Kudos

Normally you would set a variable in the onInit of the controller

this.dialog

and then set your dialog to it

this.dialog = new sap.m.Dialog({...


Regards,

Jamie

SAP - Technology RIG

Former Member
0 Kudos

I have the same issue, and setting the dialog as this.dialog = new ... does not help, any other idea?

Regards,

Matevz