Think of this scenario, while executing create opetation through web page, you have to D&D Create, commit operation and attributes as a form. when you click on create button and enter values. after that click on Commit operation. Same thing we have to replicate through programmatically.
Before writting code for executing operation some points keep in mind::
1. Attribute Binding should be present onto page.
2. If binding is not present then add attributes onto page.
3. D&D Create and Commit operation onto page or add through bindings.
- Get current binding entry and extract operational binding for CREATE operation.
BindingContainer DcCon = BindingContext.getCurrent().getCurrentBindingsEntry();
OperationBinding oper = DcCon.getOperationBinding("Create");
Object p1 = oper.execute();
- Get attribute bindings for 'Usrname', 'Asin', 'Shelf' and 'Comments' attributes.
AttributeBinding userName = (AttributeBinding) DcCon.getControlBinding("Usrname");
userName.setInputValue("rashmi");
AttributeBinding asinVal = (AttributeBinding) DcCon.getControlBinding("Asin");
asinVal.setInputValue("112456");
AttributeBinding shelfVal = (AttributeBinding) DcCon.getControlBinding("Shelf");
shelfVal.setInputValue("To Be Read");
AttributeBinding comments = (AttributeBinding) DcCon.getControlBinding("Comments");
comments.setInputValue("I am newly inserted");
- Get operation binding for Commit operation and execute it.
OperationBinding oper1 = DcCon.getOperationBinding("Commit");
oper1.execute();