on 08-13-2012 10:38 PM
<!
DOCTYPE html>
<
html><head>
<meta http-equiv='X-UA-Compatible' content='IE=edge' />
<meta charset="UTF-8">
<title>test</title>
<script id='sap-ui-bootstrap' type='text/javascript'
src='/SAPUI5_P2/resources/sap-ui-core.js'
data-sap-ui-theme='sap_goldreflection'
data-sap-ui-libs='sap.ui.commons,sap.ui.ux3'></script>
<!-- add 'sap.ui.table' and/or other libraries if required -->
<
script>
// JSON sample data
var data = {
firstName:
"John", lastName: "Doe",
birthday: { day: 01, month: 05, year: 1982 },
address:[{ city:
"Heidelberg" }], enabled: true
};
var oModel = new sap.ui.model.json.JSONModel(); // create JSON model instance
oModel.setData(data);
// set the data for the model
sap.ui.getCore().setModel(oModel);
// assign the model to the core
var oTxt = new sap.ui.commons.TextField("txtField", {
value:
"{firstName}" // binding syntax using curly braces
});
// generic bind method bindProperty(control property, model property)
oTxt.bindProperty(
"enabled", "enabled");
oTxt.placeAt(
"content");
</
script>
</
head>
<
body class='sapUiBody'>
<div id='content'></div>
</
body>
</
html>
Its resolved now. I think while binding to control reverse slash(/) required like
{/firstName}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rama,
I tried out your code in my own project, all I had to do to get it to work was fix the reference to the sap-ui-core.js file. Here is the code after I made the change:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='X-UA-Compatible' content='IE=edge' />
<meta charset="UTF-8">
<title>test</title>
<script id='sap-ui-bootstrap' type='text/javascript'
src='resources/sap-ui-core.js'
data-sap-ui-theme='sap_goldreflection'
data-sap-ui-libs='sap.ui.commons,sap.ui.ux3'></script>
<!-- add 'sap.ui.table' and/or other libraries if required -->
<script> // JSON sample data
var data = { firstName: "John",
lastName: "Doe",
birthday: { day: 01, month: 05, year: 1982 },
address:[{ city: "Heidelberg" }],
enabled: true };
var oModel = new sap.ui.model.json.JSONModel();
// create JSON model instance
oModel.setData(data); // set the data for the model
sap.ui.getCore().setModel(oModel); // assign the model to the core var
oTxt = new sap.ui.commons.TextField("txtField", { value: "{firstName}" });
// generic bind method bindProperty(control property, model property)
oTxt.bindProperty("enabled", "enabled"); oTxt.placeAt( "content");
</script>
</head>
<body class='sapUiBody'>
<div id='content'></div>
</body> </html>
Your project should have a resources folder in it. You can reference the sap-ui-core.js using src="resources/sap-ui-core.js"
Here is the result:
I hope this helps,
Simon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rama,
I just downloaded it from here: http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/webcontent/uuid/c08465d5-b833-2f10-e59d-f67a5c...
Make sure you have the most recent release from SAP.
Thanks,
Simon
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.