Thursday, October 4, 2012

Programmatic Data Retrieval in ADF



// Get the binding context and the binding entry for the current view.
DCBindingContainer bindings =  
(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
   
// Get the iterator binding instance from the iterators binded to the view
DCIteratorBinding it = (DCIteratorBinding)bindings.get("UsersView1Iterator");
   
// Retrieve the view object instance from the iterator binding, this would have the result set.
// Set the where clause with the attribute and view name
ViewObject viewObject = it.getViewObject();
viewObject.setWhereClause("USERNAME = '" + username +"'");
   
// Execute the query to retrieve the record
viewObject.executeQuery();
     
   
// Retrieve the Row from the row set retrieved
// viewObject.hasNext() can be used to iterate through the row set.
Row r = viewObject.next();
   
// Now obtain the value from the retrieved row.
String userid = r.getAttribute("AccountId").toString();
   

No comments:

Post a Comment