<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
	<meta charset="UTF-8">
	<title>SAPUI5 HelloWorld</title>
	<script
		id="sap-ui-bootstrap"
		src='https://sapui5.hana.ondemand.com/resources/sap-ui-core.js'
		data-sap-ui-theme="sap_belize"
    data-sap-ui-libs="sap.m"
		data-sap-ui-resourceroots='{
				"saphanatutorial": "./"
			}'>
	</script>
	
	<script>
		sap.ui.getCore().attachInit(function () {
		  
  		var oView = sap.ui.view({
            				viewName: "saphanatutorial.view.HelloWorld",
            				type:sap.ui.core.mvc.ViewType.XML,
            			});
      oView.placeAt("content");
      
		});
	</script>
	
</head>
<body class="sapUiBody" id="content">
</body>
</html>
<mvc:View
	xmlns="sap.m"
	xmlns:mvc="sap.ui.core.mvc"
	controllerName="saphanatutorial.controller.HelloWorld" >
	
	<Button 
			text="Destroy View and Controller" 
			press="onPress"/>

</mvc:View>
sap.ui.define([
  "sap/ui/core/mvc/Controller"
], function(Controller) {

  return Controller.extend("saphanatutorial.controller.HelloWorld", {

    onInit: function() {
      alert("onInit function called");
    },
    
    onBeforeRendering: function() {
      alert("onBeforeRendering function called");
    },
    
    onAfterRendering: function() {
      alert("onAfterRendering function called");
    },
    
    onExit: function() {

		  console.log("onExit() of controller called...");
		  alert("onExit function called");
	  },
    
    onPress: function(Event) {
      this.getView().destroy();
    }

  });
});