ERPClimb logoERPClimb
SAPUI5 and SAP Fiori Tools
RAP / CDS / ODataintermediate 10 min read

SAPUI5 and Fiori Tools Part 4: Routing, Navigation, Fragments and Dialogs

Preview · a free account unlocks the full lesson

Key takeaway

Add navigation to a freestyle SAPUI5 app: configure routes and targets in manifest. json, navigate with parameters, read them in the target view, and reuse UI with fragments and dialogs.

In this lessonShow sections

Visual overview

SAPUI5 and Fiori Tools Part 4: Routing, Navigation, Fragments and Dialogs — learning sheetFlow: Add the "detail" route and target (code example) → In the list, navigate on item press → In the detail, bind in _onMatched → Add a "Reject" dialog fragment and open it from a button. Key ideas: ROUTING CONCEPTS; CONFIGURATION IN MANIFEST.JSON; INITIALIZE AND NAVIGATE; READ PARAMETERS IN THE TARGET VIEW. Watch out: Always bind the detail view in the pattern-matched handler, not in onInit.ERPClimb.com / RAP / LESSON 4/7 / LEARNING SHEETSAPUI5 and Fiori Tools Part 4: Routing, Navigation,Fragments and Dialogs1 · HOW IT FLOWS1Add the"detail"route and target…2In the list,navigate on itempress3In the detail,bind in_onMatched4Add a"Reject"dialog fragment…2 · KEY IDEAS EXPLAINEDRouting ConceptsRouter — reads the URL hash and shows the rightview.Route — a name and a URL pattern, e.g."detail" with pattern"requests/{requestId}".Configuration In Manifest.jsonUnder "sap.ui5" → "routing":config (router class, view type, path, controlId,controlAggregation), routes and targets. Fiori…Initialize And NavigateComponent.js: this.getRouter().initialize() ininit.In the list controller:this.getOwnerComponent().getRouter().navTo("detail",{ requestId: sId }).Read Parameters In The Target ViewIn the detail controller onInit:router.getRoute("detail").attachPatternMatched(this._onMatched,this). In _onMatched, read…3 · REMEMBER · WATCH OUTRememberRoutes (URL patterns) and targets (views) are configured inmanifest.json — not in code.Navigate with oRouter.navTo("detail", { requestId }) andread parameters in attachPatternMatched.Fragments are reusable UI pieces without their own controller; dialogsare usually fragments.!Watch outAlways bind the detail view in thepattern-matched handler, not inonInit.4 · IN A REAL PROJECTA freestyle app created detail views in controller code and passed the selected object through a globalvariable. Refreshing the browser on the detail page produced an empty screen, and bookmarks did not work. Theteam moved navigation to manifest routing with a "requests/{requestId}" pattern and bound the detail…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Routes, which are URL patterns, and targets, which are views, are configured in manifest.json rather than in code. Navigation happens via oRouter.navTo("detail", { requestId }), and parameters are read back in attachPatternMatched. Fragments are reusable pieces of UI without their own controller, and dialogs are usually built as fragments. One rule to keep in mind: always bind the detail view inside the pattern-matched handler, never in onInit.

Parts 1 through 3 built views, models and data binding for a single page. Real apps have several pages, so this part adds list-to-detail navigation and a dialog to the purchase request app.

A few routing concepts underpin all of this. The router reads the URL hash and shows the right view accordingly. A route is a name paired with a URL pattern — for example "detail" with pattern "requests/{requestId}". A target specifies which view to display and where, meaning which control aggregation of the app container it goes into. The URL hash itself, something like #/requests/4711, is what makes pages bookmarkable and lets the browser's back button work.

All of this routing configuration lives under "sap.ui5" → "routing" in manifest.json: a config section (router class, view type, path, controlId, controlAggregation), plus the routes and targets themselves. Fiori tools generators create this structure for you initially, and you add routes to it as the app grows.

Free account

Create a free account to keep reading

You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.

  • Full explanation
  • Code example
  • Real project scenario
  • Common mistakes
  • Best practices
  • Interview angle

One tap with Google works too. Every topic keeps its first lesson open to everyone.

Keep exploring

Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.