Skip to Content
avatar image
Former Member

SAPUI5 page View reload issue

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();

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    Apr 09, 2016 at 02:24 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Ramesh Shrestha

      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.

  • avatar image
    Former Member
    Apr 09, 2016 at 04:07 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 06, 2016 at 01:24 PM

    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

    Add comment
    10|10000 characters needed characters exceeded