<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: SAPUI5 Component.getRouter() does not exist in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/sapui5-component-getrouter-does-not-exist/qaa-p/13884783#M4886374</link>
    <description>&lt;P&gt;I guess something is missing in your project. Have a look at the TS sample here:&amp;nbsp;&lt;A href="https://sap-samples.github.io/ui5-typescript-walkthrough/step-30/README.html" target="_blank"&gt;https://sap-samples.github.io/ui5-typescript-walkthrough/step-30/README.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 01 Oct 2024 16:40:53 GMT</pubDate>
    <dc:creator>WouterLemaire</dc:creator>
    <dc:date>2024-10-01T16:40:53Z</dc:date>
    <item>
      <title>SAPUI5 Component.getRouter() does not exist</title>
      <link>https://community.sap.com/t5/technology-q-a/sapui5-component-getrouter-does-not-exist/qaq-p/13884643</link>
      <description>&lt;P&gt;Hello, I'm working on a TypeScript SAPUI5 app, in a table I need to route the user on the Object Page linked to the row.&lt;/P&gt;&lt;P&gt;Unfortunately, in the view controller when I want to get the Router to proceed with routing, i'm struck with an error: `&lt;SPAN&gt;Property 'getRouter' does not exist on type 'Component'.`&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here's the code :&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;onSessionPress(oEvent: any): void {
        const oItem = oEvent.getSource();
        const sSessionID = oItem.getBindingContext().getProperty("ID");
        const oRouter = this.getOwnerComponent()?.getRouter();
        
        oRouter.navTo("SessionObjectPage", {
            ID: sSessionID
        });
    }&lt;/LI-CODE&gt;&lt;P&gt;In the manifest.json, the routing is defined like this:&lt;/P&gt;&lt;LI-CODE lang="json"&gt;"routing": {
      "routes": [
        {
          "name": "SessionsSessionsListPage",
          "pattern": ":?query:",
          "target": "SessionsSessionsListPage"
        },
        {
          "name": "SessionsSessionObjectPage",
          "pattern": "Sessions({SessionsKey}):?query:",
          "target": "SessionsSessionObjectPage"
        }
      ],
      "targets": {
        "SessionsSessionsListPage": {
          "type": "Component",
          "id": "SessionsSessionsListPage",
          "name": "sap.fe.core.fpm",
          "options": {
            "settings": {
              "viewName": "raceanalysis.ext.view.SessionsListPage",
              "contextPath": "/Sessions",
              "navigation": {
                "Sessions": {
                  "detail": {
                    "route": "SessionsSessionObjectPage"
                  }
                }
              }
            }
          }
        },
        "SessionsSessionObjectPage": {
          "type": "Component",
          "id": "SessionsSessionObjectPage",
          "name": "sap.fe.core.fpm",
          "options": {
            "settings": {
              "viewName": "raceanalysis.ext.view.SessionObjectPage",
              "contextPath": "/Sessions"
            }
          }
        }
      },
      "config": {}
    }&lt;/LI-CODE&gt;&lt;P&gt;The only issue remotely similar I found is this:&amp;nbsp;&lt;A href="https://community.sap.com/t5/technology-q-a/navigation-problem/qaq-p/11609343" target="_blank"&gt;https://community.sap.com/t5/technology-q-a/navigation-problem/qaq-p/11609343 &lt;/A&gt;&amp;nbsp;. But it's quite old and didn't found a clear answer.&lt;BR /&gt;&lt;BR /&gt;Any help is appreciated !&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 14:13:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sapui5-component-getrouter-does-not-exist/qaq-p/13884643</guid>
      <dc:creator>koebelt</dc:creator>
      <dc:date>2024-10-01T14:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: SAPUI5 Component.getRouter() does not exist</title>
      <link>https://community.sap.com/t5/technology-q-a/sapui5-component-getrouter-does-not-exist/qaa-p/13884745#M4886363</link>
      <description>&lt;P&gt;Hi there, do you have this line in your Component file?&lt;/P&gt;&lt;P&gt;this.getRouter().initialize();&lt;BR /&gt;&lt;BR /&gt;In your code you are referring to getOwnerComponent (which is the Component file in your case).&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 15:51:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sapui5-component-getrouter-does-not-exist/qaa-p/13884745#M4886363</guid>
      <dc:creator>Noel_Hendrikx</dc:creator>
      <dc:date>2024-10-01T15:51:15Z</dc:date>
    </item>
    <item>
      <title>Re: SAPUI5 Component.getRouter() does not exist</title>
      <link>https://community.sap.com/t5/technology-q-a/sapui5-component-getrouter-does-not-exist/qaa-p/13884783#M4886374</link>
      <description>&lt;P&gt;I guess something is missing in your project. Have a look at the TS sample here:&amp;nbsp;&lt;A href="https://sap-samples.github.io/ui5-typescript-walkthrough/step-30/README.html" target="_blank"&gt;https://sap-samples.github.io/ui5-typescript-walkthrough/step-30/README.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 16:40:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sapui5-component-getrouter-does-not-exist/qaa-p/13884783#M4886374</guid>
      <dc:creator>WouterLemaire</dc:creator>
      <dc:date>2024-10-01T16:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: SAPUI5 Component.getRouter() does not exist</title>
      <link>https://community.sap.com/t5/technology-q-a/sapui5-component-getrouter-does-not-exist/qaa-p/13885311#M4886459</link>
      <description>&lt;P&gt;use the generic UIComponent.getRouterFor method.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import UIComponent from "sap/ui/core/UIComponent";

onPress(): void {
        const router = UIComponent.getRouterFor(this);
        router.navTo("detail");
    }    
};&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 02 Oct 2024 08:45:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sapui5-component-getrouter-does-not-exist/qaa-p/13885311#M4886459</guid>
      <dc:creator>FlorianVogt</dc:creator>
      <dc:date>2024-10-02T08:45:44Z</dc:date>
    </item>
  </channel>
</rss>

