text: sap.ui.define([
  		'jquery.sap.global',
  		'sap/ui/core/Fragment',
  		'sap/ui/core/mvc/Controller',
  		'sap/ui/model/json/JSONModel'
  	], function(jQuery, Fragment, Controller, JSONModel) {
  	"use strict";
  
  	var PageController = Controller.extend("sap.ui.layout.sample.SimpleForm471.Page", {
  
  		onInit: function (oEvent) {
  
  			// set explored app's demo model on this sample
  			var oModel = new JSONModel(jQuery.sap.getModulePath("sap.ui.demo.mock", "/supplier.json"));
  			oModel.attachRequestCompleted(function() {
  				this.byId('edit').setEnabled(true);
  			}.bind(this));
  			this.getView().setModel(oModel);
  
  			this.getView().bindElement("/SupplierCollection/0");
  
  			// Set the initial form to be the display one
  			this._showFormFragment("Display");
  
  			// to navigate to the page on phone and not show the split screen items
  			var oSplitContainer = this.byId("SimpleFormSplitscreen");
  			oSplitContainer.toDetail(this.createId("page"));
  
  		},
  
  		onExit : function () {
  			for (var sPropertyName in this._formFragments) {
  				if (!this._formFragments.hasOwnProperty(sPropertyName)) {
  					return;
  				}
  
  				this._formFragments[sPropertyName].destroy();
  				this._formFragments[sPropertyName] = null;
  			}
  		},
  
  		handleEditPress : function () {
  
  			//Clone the data
  			this._oSupplier = jQuery.extend({}, this.getView().getModel().getData().SupplierCollection[0]);
  			this._toggleButtonsAndView(true);
  
  		},
  
  		handleCancelPress : function () {
  
  			//Restore the data
  			var oModel = this.getView().getModel();
  			var oData = oModel.getData();
  
  			oData.SupplierCollection[0] = this._oSupplier;
  
  			oModel.setData(oData);
  			this._toggleButtonsAndView(false);
  
  		},
  
  		handleSavePress : function () {
  
  			this._toggleButtonsAndView(false);
  
  		},
  
  		_formFragments: {},
  
  		_toggleButtonsAndView : function (bEdit) {
  			var oView = this.getView();
  
  			// Show the appropriate action buttons
  			oView.byId("edit").setVisible(!bEdit);
  			oView.byId("save").setVisible(bEdit);
  			oView.byId("cancel").setVisible(bEdit);
  
  			// Set the right form type
  			this._showFormFragment(bEdit ? "Change" : "Display");
  		},
  
  		_getFormFragment: function (sFragmentName) {
  			var oFormFragment = this._formFragments[sFragmentName];
  
  			if (oFormFragment) {
  				return oFormFragment;
  			}
  
  			oFormFragment = sap.ui.xmlfragment(this.getView().getId(), "sap.ui.layout.sample.SimpleForm471." + sFragmentName);
  
  			this._formFragments[sFragmentName] = oFormFragment;
  			return this._formFragments[sFragmentName];
  		},
  
  		_showFormFragment : function (sFragmentName) {
  			var oPage = this.byId("page");
  
  			oPage.removeAllContent();
  			oPage.insertContent(this._getFormFragment(sFragmentName));
  		}
  
  	});
  
  
  	return PageController;
  
  });
  