Quantcast
Channel: SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 789

UI5 Boilerplate explained (Part 1)

$
0
0

In this blog I will describe the structure and concepts behind the UI5 SplitApp Boilerplate. It is a template/skeleton for Mobile UI5 Apps and follows the "Mobile First" approach, but also works on desktop (Thanks to the great sap.m controls).


The UI5 Boilerplate can be understood as starting point for your own UI5 Development, both for OpenUI5 and SAPUI5 Apps.

 

The Boilerplate provides a basic application and file structure, implements some core features (navigation, i18n) and contains example views/controllers for different purposes. The UI5 SplitApp Boilerplate code is hosted on Github: 6of5/UI5SplitApp-Boilerplate · GitHub

 

The UI5 Boilerplate also supports SAP and also Non-SAP Development approach, this is reflected in two different git branches:

 

non-SAP centric Development ScenarioSAP-centric Development Scenario
Development ToolAny IDE with Git Support (Sublime Text, Eclipse, IntelliJ,…)Eclipse 4.3 with SAP UI Development Toolkit for HTML5 (SAP UI5 Toolkit)
Git BranchmastereclipseKepler
Git Clone Commandgit clone https://github.com/6of5/UI5SplitApp-Boilerplate.gitgit clone -b eclipseKepler https://github.com/6of5/UI5SplitApp-Boilerplate.git
More Informationhttp://scn.sap.com/community/developer-center/front-end/blog/2014/01/13/ui5-mobile-splitapp-boilerplate/UI5 Boilerplate with Eclipse + SAPUI5 Toolkit
local Dev Runtime Optionsnode.js, Apache HTTP, Apache TomcatWeb App Preview, Apache Tomcat, HANA Cloud Local Runtime

 

Application Structure and File Structure

UI5 Boilerplate is structured via the following folders:

Foldercontains
appUI5 Application Component, which is responsible for general tasks, like initialize core models like i18n
cssCSS files go here
i18nresource bundles for internationalization (i18n) are stored in this folder
imgassets like images, logos,….
jsgeneral javascript files, e.g. app.js
modelUI5 model information (like json, xml files)
viewUI5 view files (XMLViews, JSViews) and the corresponding controllers

 

Let's have a look at the index.html file first:

UI5bp-expl1_01m.png

It is a normal HTML5 document file. After the meta declaration for IE the UI5 bootstrap script is declared. The boilerplate offers here in comments some alternative  sources for the UI5 bootstrap (OpenUI5 external, SAPUI5 external, local SAPUI5 from SAP UI5 Toolkit or providing it via local web server). With local options you can define yourself which dedicated UI5 version you want to use. The index.html links to the JavaScript file app.js:

 

app.js (declare UI5 resources / 'start' Application Component)

UI5bp-expl1_02.png

in the app.js we define where UI5 resources are located. These are in the folders app, model and view. So UI5 will be able to use resources within these folders.And we specify that we require app.Component. This Component represents our Application. We create an ComponentContainer with name "app" and attach it to the DOM element with the id "root", which in our case is the body tag <body class="sapUiBody" id="root">. This willcreate and run our Component (Application):

 

Component.js (Application Component)

UI5bp-expl1_03.png

In the Component (Application) we create the App.view (which represents the UI of our Application) and create the i18n model and attach this to the App.View. Within the component further general tasks could be executed, like loading master data, which can then be used throughout the application. Now lets have a look at the App View:

 

App.view.js (Application UI)

UI5bp-expl1_04.png

In the App View we create a SplitApp which will enable the "iPad" like UI Style. We can then define the Master Page(s) which will be on the smaller left side of the screen (here the Menu View)  and also the Detail Pages (CoffeeList View and Info View). Both JSViews or XMLViews are possible as you can see. And of course you could also use the other view types here. The App View is now returning the SplitApp as member of the mobile Shell. The result can be seen in the browser (with UI5 Boilerplate Version 0.6.0):

UI5bp-expl1_05.png

Next

In the next blog article I want to explain, how you can easily extend the UI5 Boilerplate with further Pages.


Viewing all articles
Browse latest Browse all 789

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>