首页 > SAP > SAPUI5 > Page Navigation in SAPUI5/SAP Fiori using Routing
2019
08-27

Page Navigation in SAPUI5/SAP Fiori using Routing

Hello everyone, in this SAPUI5 tutorial we will learn about page navigation in SAPUI5/SAP Fiori using Routing-制造途程,生产某一机种的过程. Lets get started.

1.What is Routing-制造途程,生产某一机种的过程 in SAPUI5/SAP Fiori

Routing-制造途程,生产某一机种的过程 is a mechanism used to navigate between views in SAPUI5/SAP Fiori applications. There are two main routing classes used for this purpose, they are

sap.ui.core.routing.Targets

sap.ui.core.routing.Route

In this tutorial we will learn how to use sap.ui.core.routing.Targets.

2.SAPUI5 Version Needed

1.28

3.Step-by-Step Procedure

1. Create a new SAPUI5 Application Project in Eclipse IDE.

New Application Project for SAPUI5

2. In the Create a New View window, provide the initial view name and choose the type of view as XML.

Page Navigation in SAPUI5/SAP Fiori using Routing - 第2张  | 优通SAP
Create a New View

3. Now application structure will like below.

Page Navigation in SAPUI5/SAP Fiori using Routing - 第3张  | 优通SAP
Application Structure

4. As we require two views to demonstrate view navigation, create two views in the same way.Create a new folder to move all views into this folder, as this a best practice to have all views in one place.

5. Now the application structure will look like below.

Project Structure

6. Go to the First view and add Text , a button to navigate to second view and Go to the second view, add Text.Below is the  code for both First and Second view.

First.view.xml


Second.view.xml

7. The configuration of the routing in maintained in a separate file called Component.js.So create a new file with the name “Component.js” and copy the below code.

8. Component.js file contains routing information with possible target of navigation.

9. As we have defined the routing, next would be implementing the “onPress” event on the first view to navigate to second view and “onPress” event in the second view to come back to first view. Go the controller of the First view and copy the below code.

10. display( ) method in the routing class is used to call the next page.

11. Main View and its controllers is code is below. Main view just contains the App, its kind of holder for all the views.

12. Final SAPUI5 project structure will look like below.

Page Navigation in SAPUI5/SAP Fiori using Routing - 第5张  | 优通SAP
Project Structure

12. Save the project and run the index.html file to see the output. You should see First View with a text and button like below.


最后编辑:
作者:yangsen
有需要可在文章留言或者邮件yan252@163.com给我。

留下一个回复

你的email不会被公开。

12 − 2 =