Saturday, May 11, 2013

Adf 11G : How to Insert a row programatically from AMImpl?

Adf 11G : How to Insert a row programatically from AMImpl?

Put the below code into XXAMImpl.java and expose it as Client Inteface.


    public void addNewStudent(String id, String name){
     
             EntityDefImpl studentEODef  =   StudentEOImpl.getDefinitionObject();
             StudentEOImpl newStudent =
                (StudentEOImpl)studentEODef.createInstance2(this.getDBTransaction(), null);
                newStudent.setAttribute("Roll",id);
                newStudent.setAttribute("Name",name);
         
                this.getDBTransaction().commit();
            }


Backing Bean Code:
    public String create() {


        BindingContainer bindings = getBindings();
        OperationBinding operationBinding = bindings.getOperationBinding("addNewStudent");

//Either Add the below Two line code for set the Parameter values(ex, id & name) or Set the parameter value at pageDef.xml file

        operationBinding.getParamsMap().put("id", this.it1.getValue().toString());
        operationBinding.getParamsMap().put("name", this.it2.getValue().toString());
     
        Object result = operationBinding.execute();
        if (!operationBinding.getErrors().isEmpty()) {
            return null;
        }
        return null;
    }
-----------------------