Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use Shell, App, Container, Page, View, and SplitApp

Tags:

sapui5

Recently I have created two UI5 apps using shell -> views and appContainer -> views. Both results in same output. I'm confused when to use Shell, App, Container, Page, View, and SplitApp in UI5.

I would like to know the differences between them. Also please describe the best practices of using the above containers from your experiences.

Graphical explanation would help a lot in understanding.

like image 677
Natarajan Srikanta Avatar asked Jul 17 '15 07:07

Natarajan Srikanta


People also ask

Why do we use shell in ui5 view?

The shell, no surprise here, is a parent container you can use for views. However, in contrast to other containers, it allows you to limit the app width for large devices. If you want to achieve this for your application, this is your control.

What is Shell in sapui5?

Overview. The Shell control can be used as root element of applications. It can contain an App or a SplitApp control. The Shell provides some overarching functionality for the overall application and takes care of visual adaptation, such as a frame around the App, on desktop browser platforms. Constructor.

What is the difference between navcontainer and splitapp control?

Each NavContainer has a container of its own—the SplitApp control splits the application into two containers: The sap.m.SplitContainer has the same features as the sap.m.SplitApp. The use case of a SplitContainer control is when a SAPUI5 application has as its root the sap.m.App, but it also needs to feature a master-detail view:

What is the splitapp control?

The sap.m.SplitApp is just the same as sap.m.App except that it features two sap.m.NavContainer in the desktop and tablet mode—if it is running on a phone it has just as the sap.m.App one nav container control. Each NavContainer has a container of its own—the SplitApp control splits the application into two containers:

What is the shell in Android?

The shell, no surprise here, is a parent container you can use for views. However, in contrast to other containers, it allows you to limit the app width for large devices. If you want to achieve this for your application, this is your control.

Is the shell control mandatory for an application?

However, the Shell control isn’t mandatory for an application. Either the sap.m.App or the sap.m.SplitApp control needs to be a part of an SAPUI5 application for two reasons: Each tweak the HTML in a way that makes it suitable for mobile apps.


1 Answers

You're right, there are a lot of container controls and this can be confusing. So let me give a brief overview:

sap.m.Shell

The shell, no surprise here, is a parent container you can use for views. However, in contrast to other containers, it allows you to limit the app width for large devices. If you want to achieve this for your application, this is your control.

sap.m.Shell

sap.m.App | sap.m.SplitApp

Both, the sap.m.App and the sap.m.SplitApp are probably the most used parent controls. In fact, one of them should always be part of your mobile application as they do some HTML modifications to improve the experience on mobile devices (see sap/ui/util/Mobile.init for details). Of course, they can be a child of any Shell. Furthermore, they are important since they extend a sap.m.NavContainer and therefore offer navigation capabilities. For example, the sap.m.App has a pages aggregation. By calling to, you can simply navigate from one page to another (once you are using routing, this is done by the router). The sap.m.SplitApp contains two NavContainers. One for the Master Area and another for the Detail Area. In addition, it offers you to manage one background across your application.

sap.m.SplitContainer

Talking about containers one should mention the sap.m.SplitContainer. Basically, it offers the same capabilities as the sap.m.SplitApp but since you should have only one App (sap.m.App or sap.m.SplitApp) in your application, you can use this control if you want to start a Master/Detail view once you navigate deeper in your application.

sap.ui.core.mvc.View

The view (and all of its sub types like JSView, XMLView, HTMLView) reflect one simple page or area of a page. In contrast to all other containers, a view may have a controller associated and enables you to implement the View/Controller part of MVC.

sap.ui.core.Fragment

Fragments are light-weight variants of a view. They are used like views and they behave similar, but have no controller associated by default. However, you can use simple objects with functions as a controller replacement if necessary. Fragments can be used if you have a particular part of the User Interface you want to externalize to a different file (and maybe reuse it multiple times).

Examples

Regarding an architecture of your application, it depends on what you want to display (limited app width, Master/Detail, ...). Almost every combination is possible but I think it is still best practices to have only one App object per application. If you don´t need a feature of one of the Shells you can simply omit it and make your app object the top level container. Some examples for an architecture could look like this:

SplitApp or SplitContainer in a sap.m.Shell

sap.m.Shell
    sap.m.SplitApp
        sap.ui.core.view.XMLView (Master)
            sap.m.Page

        sap.ui.core.view.XMLView (Detail)
            sap.m.Page

ui5 master detail pages within splitapp within shell


SplitApp or SplitContainer without Shell

sap.m.SplitApp
    sap.ui.core.view.XMLView (Master)
        sap.m.Page

    sap.ui.core.view.XMLView (Detail)
        sap.m.Page

ui5 master detail pages within splitapp without shell


sap.m.App in a sap.m.Shell

sap.m.Shell
    sap.m.App
        sap.ui.core.view.JSView
            sap.m.Page

ui5 page within view within app within shell


sap.m.App without any Shell

sap.m.App
    sap.ui.core.view.XMLView
        sap.m.Page

ui5 page within view within app without shell

like image 135
Tim Gerlach Avatar answered Oct 16 '22 10:10

Tim Gerlach