Skip to Content

Navigation between View 1 and View 2

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;


oModel Refresh();


View2 Controller:






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.



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jun 12, 2018 at 10:55 PM

    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

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 13, 2018 at 02:42 PM

    Thank you, Srikanth.

    I will try it. And let you know.



    Add comment
    10|10000 characters needed characters exceeded