Skip to Content
0
May 02, 2017 at 11:39 AM

error in binding JSON in SAPUI5 blank screen

135 Views Last edit May 02, 2017 at 11:40 AM 3 rev

Hi Friends,

I am trying to bind JSON model in my view but viewing a blank screen as output. Please check the below code and help where am I committing mistake.

index.html:

<!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>


		<script src="resources/sap-ui-core.js"
				id="sap-ui-bootstrap"
				data-sap-ui-libs="sap.m"
				data-sap-ui-xx-bindingSyntax = "complex"
				data-sap-ui-theme="sap_bluecrystal">
		</script>
		<!-- only load the mobile lib "sap.m" and the "sap_bluecrystal" theme -->


		<script>
				sap.ui.localResources("exercise2");
				var app = new sap.m.App({initialPage:"idView11"});
				var page = sap.ui.view({id:"idView11", viewName:"View1.View", type:sap.ui.core.mvc.ViewType.XML});
				app.addPage(page);
				app.placeAt("content");
		</script>


	</head>
	<body class="sapUiBody" role="application">
		<div id="content"></div>
	</body>
</html>

View

<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
		controllerName="View1.Controller" xmlns:html="http://www.w3.org/1999/xhtml">
	<Page title="Title">
		<content>
	
	<VBox>
		<HBox>
		<Text text = "{/Products/0/Price}"></Text>
		<Input id = "text" value = "{path: '/Products/0/Price' } "
				width = "100%"></Input>
		</HBox>
		
		<HBox>
		<Text text = "Last Name"></Text>
		<Input placeholder = "Enter last name: "
				width = "100%"></Input>
		</HBox>
		
		<Button text = "Press here"  press = "click"></Button>
	</VBox>
				
		</content>
	</Page>
</core:View>

Controller:
sap.ui.controller("View1.View", {
	
	onInit : function() {
		
		var Model1 = new sap.ui.model.json.JSONModel();
		model1.loadData("model/expense.json");
		sap.ui.getCore().setModel(Model1);
	}
});