cancel
Showing results for 
Search instead for 
Did you mean: 

How to define SAP UI5 Event Handlers while not using MVC Pattern?

Former Member
0 Kudos

We were having an issue in IE9(Quirks Mode) SAP MII Portal where SAP UI5 pages were not getting loaded and it is because of the MVC Pattern what we were using to define separate view and controller page. So, we are now using view and controller as a simple javascript file and defining the UI5 controls to overcome the IE9 portal issue. But SAP UI5 has its own event handlers like "onAfterRendering"/"onInit"/"onBeforeRendering", so using  simple JS file (not using MVC), these functions can not be called by itself. Other simple functions like Button Press/Link Press, they all are working fine defined in the controller page.

This is what we are doing right now, but its not working.

function onAfterRendering() {

alert("OnAfterRendering");

}


So if anyone has any idea about it, please share, it will be highly appreciated.

Thanks always,

Ushinar

Accepted Solutions (1)

Accepted Solutions (1)

Private_Member_14935
Active Participant
0 Kudos

Hi Ushinar,

Even when you define SAP UI5 controls within normal javascript files you should be able to listen to SAP UI5 events. You can try the following:

Say, you have defined a SAP UI5 MatrixLayout as shown below:

var oLayout = new sap.ui.commons.layout.MatrixLayout();

And you want to do something in the onAfterRendering event of this layout, then you can do this:

oLayout.addEventDelegate({

  onAfterRendering : function () {

     alert("onAfterRendering...!!");

     }

});

Hope this helps!

Regards,

Ria

Former Member
0 Kudos

Hi Ria,

It is working fine now.

Let's see...

Thank you so much..

Ushinar

Former Member
0 Kudos

Hey Ria,

Nice Workaround.

Regards,

Rohit Negi.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Ushinar,

I don't think this will work as these listener methods would only work with the MVC architecture of SAP UI5.

Try to replace all these listeners by listener methods available for window and dom object like window.onload or $(document).ready.

Regards,

Rohit Negi.

Former Member
0 Kudos

Thanks Rohit,

But you see, if we use MVC pattern by creating separate view and controller page, the UI5 page does not work in IE9 MII Portal(Quirks Mode) but it works fine in Mozila/Chrome.

So, that is why we were trying to avoid the standard UI5 pattern by removing RegisterModulePath from the html page, and only defining a simple javascript function to create the main layout which is returning the main layout and calling the function on the html page, placing the main layout on the div, so all controls and functions are working fine with this even in the IE9 MII Portal(Quirks Mode) except these event handlers because we are treating the view and controller page as a simple javascript page.

So do you have any idea about how we can make it workable in IE9 MII Portal(Quirks Mode) while using MVC and also the UI5 standard event handlers?

Thanks always,

Ushinar

Former Member
0 Kudos

Hi Ushinar,

Is it a compulsion for you to use IE9 in quirks mode?

Warm Regards,

Anuj

Former Member
0 Kudos

Yes Anuj, it is compulsory because SAP MII portal runs on IE in Quirks Mode as default. MII portal can run on Standard mode on IE but as default it gets loaded in Quirks Mode.

Thanks always,

Ushinar

Former Member
0 Kudos

Hi Ushinar,

In that case, you can try using IE10 set as IE9 Quirks mode in the browser and can include meta tag in the irpt/html file of your MVC structure for IE10 standards document mode.

This way, MII portal will be loaded in IE9 quirks mode and your UI5 page with MVC structure will be rendered properly using IE10 standards mode.

You can even try if MVC works in IE9 standards mode and can include the meta tag accordingly, if you do not want to upgrade your browser, I havent tried this.

Regards,

Anuj