title: SapUI5 Router Issue With XML Views
body: <p>I'm developing a simple UI5 project be able to learn how Router works.. In that process I'm faced with an issue related to Router events. I've three XML view which names are FirstPage, SecondPage and ThirdPage. The ThirdPage is implemented inside the other two pages as following code;</p>
  
  <pre><code>&lt;mvc:XMLView viewName="SapUI5Tutorial.Application.Main.views.ThirdPage.view.ThirdPage"/&gt;
  </code></pre>
  
  <p>For example FirstPage.xml</p>
  
  <pre><code>&lt;mvc:View displayBlock="true" controllerName="SapUI5Tutorial.Application.Main.views.FirstPage.controller.FirstPage"
  xmlns:mvc="sap.ui.core.mvc"
  xmlns:core="sap.ui.core"
  xmlns:l="sap.ui.layout"
  xmlns="sap.m" height="100%"&gt;
  &lt;Page title="First Page" class="sapUiNoContentPadding"&gt;
      &lt;subHeader&gt;
          &lt;Toolbar&gt;
              &lt;VBox width="100%" alignItems="Center"&gt;
                  &lt;Button text="Second Page Link" press="handleNavSecondPage"/&gt;
              &lt;/VBox&gt;
          &lt;/Toolbar&gt;
      &lt;/subHeader&gt;
      &lt;mvc:XMLView viewName="SapUI5Tutorial.Application.Main.views.ThirdPage.view.ThirdPage"/&gt;
  &lt;/Page&gt;
  </code></pre>
  
  <p></p>
  
  <p>When I click "Second Page Link" button I'm navigating to SecondPage. But the ThirdPage is due to inside of SecondPage ThirdPage's Router function is running twice</p>
  
  <p>ThirdPage's controller;</p>
  
  <pre><code>sap.ui.define([
  "sap/ui/core/mvc/Controller",
  ], function (Controller, FragmentController) {
  "use strict";
  var base, oRouter;
  return Controller.extend("SapUI5Tutorial.Application.Main.views.ThirdPage", {
      onInit: function () {
          base = this;
          base.getView().setModel(oModel);
          oRouter = sap.ui.core.UIComponent.getRouterFor(base);
          oRouter.getRoute("FirstPage").attachMatched(base.firstPagePatternMatched, base);
          oRouter.getRoute("SecondPage").attachMatched(base.secondPagePatternMatched, base);
      },
      firstPagePatternMatched: function (oEvent) {
          console.log(oEvent)
      },
      secondPagePatternMatched: function (oEvent) {
          //Due to the third page is used for inside two other pages (FirstPage and SecondPage) this function is running twice
          console.log(oEvent)
      }
  });
  </code></pre>
  
  <p>});</p>
  
  <p>How can I prevent running twice that Router event of ThirdPage ? Thank you for your helps</p>