cancel
Showing results for 
Search instead for 
Did you mean: 

Navigation between View 1 and View 2

0 Kudos

Hello SAP UI5 experts,

I have a very basic question.

I have 2 XML views, View1 and View2. Below is my code for the two controllers.

View1 Controller:

onNavToView2 {

Navigate to View 2;

setOModel(Input);

oModel Refresh();

}

View2 Controller:

onInit{

AddDynamicControlsToView2();

}

onNavBack{

detroyDynamicControls();

Navigate To back Hash;

}

I want to perform the below steps to my application:

Step1. Provide Input 1

Step2: Click on NavToView2

Step3: After View2 display, Click on NavBack

Step4: Provide Input 2

Step5: Click on NavToView2

After Step 5, how to create my dynamic controls to view2 as the "onInit()" is not triggered for second time. Is there any other option other than using a base controller or by using another js file. Do we have any browser methods to use just like onInit().

Please Help me.

Thanks

Divya

Accepted Solutions (1)

Accepted Solutions (1)

former_member365727
Active Contributor

init() method will be called only once when the first time view is initialized.

you need to use 'routeMatched' event ....this will be called anytime this route is accessed..

check the below tutorial

https://sapui5.hana.ondemand.com/#/topic/f96d2522a5ca4382a274ae3c6d002ca0

attach the event handler for the route in init() method:

var oRouter = this.getRouter();
oRouter.getRoute("employee").attachMatched(this._onRouteMatched, this);     // route name = employee
         // _onRouteMatched - event handler ...which is called everytime the route 'employee' is accessed

0 Kudos

Thank you, Srikanth. It worked.

Answers (1)

Answers (1)

0 Kudos

Thank you, Srikanth.

I will try it. And let you know.

Regards

Divya