3
votes

I'm working with SAPUI5 and OpenUI5. I'ved developed some custom controls for now but never used the 2-Way Databinding for this controls...I've tried it with

oMyControl.bindProperty("someValue", "oModel>/testBindingValue")

What I've seen is: When watching the Model in the debugger the field aBindings have one entry:

sPath: "/testBindingValue" 
sInternalType: "int"

and the correct sInternalType of my Controls property type (in this case "int").

But when I'm watching the array oModel.oData it is empty and oModel.getProperty("/testBindingValue") is also returning undefined...but my control definitely has a value for "someValue"...So, does anyone have an idea?

Thanks, Alex

UPDATE:

Here you see my workflow:

first creating the model:

    var oModel = new sap.ui.model.json.JSONModel();
    sap.ui.getCore().setModel(oModel, 'oModel');

then initializing my control:

var oMyControl = new MyControl({
    someValue: "Test Value of the Control"
});
oMyControl.bindProperty("someValue", "oModel>/testValue");

Now, when I'm doing:

alert(oModel.getProperty("/testValue"));

I will get "undefined".

So, for normal controls this is working, for "value", "text", "visible" or "enabled" and so on..

1

1 Answers

0
votes

I'm guessing there is something in your custom control that is making this not work correctly. I have created an example of what I understand you are doing (http://jsbin.com/kiwoza/2/edit?html,console,output) and it seems to work as I'd expect. If this example is somehow different from what you're trying to accomplish please update the question with details about why it's not quite right.