HTML5 apps with SAP Web IDE on SAP HANA Cloud Platform
Last year in May the SAP HANA Cloud Platform got a really cool new feature. From May 21st, 2014 on it got very easy to deploy HTML5 apps on the SAP HANA Cloud Platform and along with that users also got Git repositories to support that new feature. At that point in time I wrote a blog post showing how to deploy HTML5 apps on SAP HANA Cloud Platform.
Since then a lot of happened and the SAP Web IDE was developed and introduced. Today a new feature was added that makes the usage of the Web IDE even easier. It’s “just” a little additional icon next to the name of your HTML5 app in the cockpit, but I really love the simplicity coming along with that so that I decided to write a new blog post to show how you can develop and deploy HTML5 apps in the build-in Web IDE of the SAP HANA Cloud Platform.
As a basis I’ll take the same code I’ve used in my initial blog, but will do everything inside the Web IDE.
This is now the step-by-step description on how to do it.
Step1: Create the destination
Before starting creating the app we’ll create a destination to the openweathermap API.
Explanation | Screenshot |
---|---|
1. Open your cockpit for your trial account on SAP HANA Cloud Platform via the link https://account.hanatrial.ondemand.com/cockpit, switch to account level on your cockpit and click on the Destinations tab |
![]() |
2. Click on New Destination & provide details for the destination Name: openweather Type: HTTP Description: Openweather map destination URL: http://api.openweathermap.org/data/2.5/weather Proxy Type: Internet Cloud Connector Version: 2 Authentication: NoAuthentication At the end click on Save |
![]() |
3. As a result you should see now your new destination listed |
![]() |
Step 2: Create the HTML5 Application
Now let’s create the HTML5 app. Pay attention to step 2 where the “magic happens” :-).
Part 3: Setup your Git settings
Last step in our preparations. We’ll setup the Git settings in the Web IDE.
Part 4: Create the app
Part 5: Provide the source code
Explanation | Screenshot |
---|---|
1. Double-click on the file called neo-app.json |
![]() |
2. Substitute the code there with the code listed here in the right on the right and after that click on the Save button on the top left. |
{ “authenticationMethod”: “none”, “routes”: [ { “path”: “/openweathermap”, “target”: { “type”: “destination”, “name”: “openweather” }, “description”: “OpenWeather System” }, { “path”: “/resources”, “target”: { “type”: “service”, “name”: “sapui5”, “entryPath”:”/resources” }, “description”: “SAPUI5” } ] } |
3. Double-click on the file called weather.view.js in the view folder |
![]() |
4. Substitute the code there with the code listed here in the right on the right and after that click on the Save button. |
sap.ui.jsview(“view.weather”, { getControllerName: function() { return “view.weather”; }, createContent: function(oController) { // Create the page and the weather tiles var mainPage = this.buildMainPage(“main”, “Welcome “, [ this.buildWeatherTile(“sofia”, “Sofia”, oController), this.buildWeatherTile(“walldorf”, “Walldorf”, oController), this.buildWeatherTile(“telaviv”, “Tel aviv”, oController), this.buildWeatherTile(“bangalore”, “Bangalore”, oController) ]); return mainPage; }, buildMainPage: function(id, title, content) { // creates the main container for the mobile application var page = new sap.m.Page(id, { title: title, showNavButton: false, content: content }); return page; }, buildWeatherTile: function(id, city, oController) { // The model contains the weather data var oModel = oController.getModelFromURL(city); // A tile is the UI element used to display the weather data var tile = new sap.m.StandardTile(id, { numberUnit: “Celsius”, infoState: “Success”, press: function() { var link = “http://openweathermap.org/city/” + this.getModel().oData.id; window.open(link, “_blank”); } }); // Bind icon path from the model to the the weather tile icon tile.bindProperty(“icon”, “/weather/0/icon”, function(bValue) { return “http://openweathermap.org/img/w/” + bValue + “.png”; }); tile.setModel(oModel); // Bind the name of the city to the tile title tile.bindProperty(“title”, “/name”, function(bValue) { var longTitle = “Current weather in ” + bValue; return longTitle; }); // Bind the weather details to the info field of tile tile.bindProperty(“info”, “/weather/0/description”); // Bind the temperature to the number field of the tile tile.bindProperty(“number”, “/main/temp”, function(bValue) { // We want Celsius var degreesCelsius = Math.round(bValue – 273.15); // Also add the Celsius sign to the temperature value return degreesCelsius + “\u00b0”; }); return tile; } }); |
5. Double-click on the file called weather.controller.js in the view folder |
![]() |
6. Substitute the code there with the code listed here in the right on the right and after that click on the Save button. |
sap.ui.controller(“view.weather”, { // reads the weather data for the given city into a new json model getModelFromURL: function(city) { var oModel = new sap.ui.model.json.JSONModel(); oModel.loadData(“/openweathermap?q=” + city, null, false); return oModel; } }); |
Part 6: Test the app and & deploy to SAP HANA Cloud Platform
I hope this step-by-step guide helps you a bit to get started with creating HTML5 apps with the Web IDE.
Best,
Rui