cancel
Showing results for 
Search instead for 
Did you mean: 

why App.view.xml ? - SAP UI5

10-19-2020 12:50 PM
alagar_pandian Participant
3752 views 7 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

Hi All,

Why should we use App.view.xml in SAP UI5 ? If we don't use this and don't add other views as pages to it, will it impact anything ?

Please enlighten me.

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

maheshpalavalli
Active Contributor

when you generate a ui5 project (worklist mainly), it generates this file and uses it as the root view.

Why?

Because the root view has App control, this is inheriting the navcontainer and now you should get an idea that App acts like a nav container, it doesn't necessarily needs to be an App control, it can be SplitApp or other controls that supports this mechanism.

It doesn't stop there, this root view is used by Routing and in the routing we mention the aggregation as pages, and provides different routes, what SAP UI5 framework does it to put the views that we mentions in the target inside the App control dynamically when the respective route pattern is matched.

We can do this manually as well, but if we provide rootView and routing, SAP will take care of dynamically showing the views bases on the pattern and makes our development effort a lot easier.

Thanks,
Mahesh

maheshpalavalli
Active Contributor
0 Likes

And one more thing, we also mention the id of the App control which is used in the App.view.xml in the routing, so the routing config know where to insert the pages, i.e., inside the App control(navContainer).

Answers (3)

Answers (3)

mariusobert
Developer Advocate
Developer Advocate

I think I understand your question now. I would say it always makes sense to have a root view, so you can share some common UI elements across your entire web app (such as the shellbar or the header/footer of the app). Which is why the manifest "asks" you for this information. It is just more convenient to implement one page per XML file and not to bother about the surrounding elements.

I think you can also use different containers besides sap.m.App as a root view. And you can also leave out the "routing" part of the manifest.json entirly if you don't want to use any container (and handle the aggregations manually).

mariusobert
Developer Advocate
Developer Advocate

Hi,

you need a view for SAPUI5 apps to declare the UI components (Shellbar, lists, tables, buttons) you want to display. A web app without any UI components wouldn't make much sense. The file name can be freely chosen but the ending must always be "view.xml".

The only exception are Fiori Elements (which already come with a default layout and content).

I hope this helped

alagar_pandian
Participant
0 Likes

sorry I think my question was not clear. I know what is the purpose of the view. But in UI5 usually we have App.view.xml as root view and then using routing we add other views against 'pages' aggregation of app view. I want to understand why so ?

App.view.xml

in manifest.json


routing:

"routing": { "config": { "routerClass": "sap.m.routing.Router", "viewType": "XML", "async": true, "viewPath": "com.mylan.notifList.view", "controlAggregation": "pages", "controlId": "oAPP", "clearControlAggregation": false }, "routes": [ { "name": "notifList", "pattern": "", "target": [ "notifList" ] }, { "name": "notifDetail", "pattern": "notifDetail/{notifID}", "target": [ "notifDetail" ] } ],

junwu
SAP Champion
SAP Champion
0 Likes

it is just general practice. you can go without it.

Ask a Question