Professional Documents
Culture Documents
Please follow the below steps to create the SAPUI5 application that allows the User to enter his
firstname and lastname and click on a Add button that inserts the entered input to the table
shown.
c. Create a SAP HANA Cloud Platform local runtime for testing the application
2. Enter C:\Users\<username>\workspace as the workspace for the application and click on the
Ok button. This launches the eclipse welcome screen as shown below
3. Close the Welcome tab.
4. From the Eclipse menu bar, select File -> New -> Other -> SAPUI5 Application Project. This opens
the dialog as shown below. Click on Next button.
2. Add the following code to the data-sap-ui-libs section. This will result in the following code in
the index.html file as shown in the snapshot.
, sap.ui.table, sap.ui.layout
Press Ctrl + S to save your changes.
3. Open the Main.view.js file from the Project Explorer. This opens the file contents in the
editor. Copy and replace the contents of the file with the below code and save it.
sap.ui.jsview("personslist.Main", {
oAppHeader.setLogoSrc("http://www.sap.com/global/images/SAPLogo.gif");
oAppHeader.setLogoText("SAP SAPUI5 Library");
oMLayout.createRow(oAppHeader);
});
oMLayout.createRow(oHLayout);
});
oMLayout.createRow(oHLayout1);
oMLayout.createRow(oButton);
title: "Personslist",
visibleRowCount : 5,
selectionMode : sap.ui.table.SelectionMode.Single,
});
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({
text: "First Name"
}),
template: new sap.ui.commons.TextField({
value: "{FirstName}"
})
}));
oTable.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({
text: "Last Name"
}),
template: new sap.ui.commons.TextField({
value: "{LastName}"
})
}));
oTable.bindRows("/items");
oMLayout.createRow(oTable);
return oMLayout;
}
});
4. Open the Main.controller.js file from the Project Explorer. This opens the file contents in the
editor. Copy and replace the contents of the file with the below code and save it.
sap.ui.controller("personslist.Main", {
/**
* Called when a controller is instantiated and its View controls (if
available) are already created.
* Can be used to modify the View before it is displayed, to bind event
handlers and do other one-time initialization.
* @memberOf personslist.Main
*/
onInit: function() {
//local data
var aData = {items:
[
{LastName: "Dente",
FirstName: "Al"
},
{LastName: "Friese",
FirstName: "Andy"
},
{LastName: "Mann",
FirstName: "Anita"
},
{LastName: "Schutt",
FirstName: "Doris"
},
{LastName: "Turner",
FirstName: "Paige"
}
]
};
this.getView().setModel(oModel);
},
/**
* Similar to onAfterRendering, but this hook is invoked before the
controller's View is re-rendered
* (NOT before the first rendering! onInit() is used for that one!).
* @memberOf personslist.Main
*/
// onBeforeRendering: function() {
//
// },
/**
* Called when the View has been rendered (so its HTML is part of the
document). Post-rendering manipulations of the HTML could be done here.
* This hook is the same one that SAPUI5 controls get after being
rendered.
* @memberOf personslist.Main
*/
// onAfterRendering: function() {
//
// },
/**
* Called when the Controller is destroyed. Use this one to free resources
and finalize activities.
* @memberOf personslist.Main
*/
// onExit: function() {
//
// }
});
c. Create a SAP HANA Cloud Platform local runtime for testing the application
2. Click on the link No servers are available. Click this link to create a new server
3. Select Java Web Server from the list available as shown below and click on Next > button
4. Click on the Browse button. This opens the dialog for selecting the SAP HANA Cloud
Platform SDK.
5. Browse to the path where you have extracted the SAP HANA Cloud Platform SDK (The SDK
would have been extracted to the location C:\dev\hanacloud.sdk\). Click on OK button to close
the dialog.
8. You should be able to see the server running locally as shown below.
1. Right click on the personslist application in the project explorer and select Run As -> Run
on Server
2. In the window opened, select the local server started and click on Finish button
3. After the application has started, you should be able to see the application running in the
browser.