cancel
Showing results for 
Search instead for 
Did you mean: 

Is there any function or Any event which triggers every time when views is loaded

nandishm
Participant
0 Kudos

Hi

In my project there is view let it be s5, i need  open dialog box depend upon the data in a model.

If i checked in Init function().... it will trigger only once. If i go to the next view and came back to s5, since model is empty it will not open dialogbox.

So is there any Function or event which calls every time, when the view is displayed .

I also tried with handleroutematched() function, but it called before the control goes to that view. SO if i open DialogBox in handleroutematched(), it close automatically when the view is loaded.

Thanks

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

You can use application context object to share and store data between the pages put your data in it before leaving the page and retrieve it after rendering the page once you get back to the original page

Former Member
0 Kudos

afterRendering / beforeRendering will work for each view, if u go to new view then the new view will have afterRendering / beforeRendering.


Back button,is special case. You can search in google, you will find different ways to handle browser back button event & u should be able to intigrate it into ui5

Former Member
0 Kudos

Hi Nandish,

You can use the beforeRendering or afterRendering method as described here:

https://sapui5.hana.ondemand.com/sdk/#docs/api/symbols/sap.ui.core.mvc.View.html

Kind regards,

Ted

nandishm
Participant
0 Kudos

Hi Ted...

Thanks for your suggestion .

But problem is afterRendering / beforeRendering will trigger only once.

If i moved to next view, again pressed back, that time it ll not trigger .

Former Member
0 Kudos

Hi Nandish,

Without more information the four events specified in the link are the ones you can use. Other events are application specific. You can trigger an event on the view when navigating but as I said, that's application specific.

jamie_cawley
Advisor
Advisor
0 Kudos

Hi Nandish,

Are you using routes?  You should be able to use the attachPatternMatched.

SAPUI5 SDK - Demo Kit

Regards,

Jamie

SAP - RIG

former_member182372
Active Contributor
0 Kudos

Jamie Cawley has a point, do something like :

this._oRouter = sap.ui.core.UIComponent.getRouterFor(this);

this._oRouter.attachRouteMatched(this._handleRouteMatched, this);

_handleRouteMatched: function (evt) {

//load a model, show a dialog

}

SandipAgarwalla
Active Contributor
0 Kudos

another option could be to use BeforeShow and beforeHide events of the Page, assuming you are using sap.m controls ( specially NavContainer  or App or SplitApp etc etc)