Wednesday, July 25, 2012

How to get RowImpl class in backing bean

It would be common requirement in ADF to get an instance for a RowImpl class in backing bean, Backing bean is associated to a page fragment, Page fragment page definition binds to a respective VOIterator.

Below are the steps to get get Row Instance in backing bean.

Step1:  Bind the view object to page definition as shown in below screen shot


Step2:   Follow the below code in Backing bean


import oracle.adf.model.binding.DCBindingContainer;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.binding.BindingContainer;
import javax.el.ELContext;
import javax.el.ExpressionFactory;
import javax.el.ValueExpression;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;


private Row getRowFromBinding(){
FacesContext facesContext = FacesContext.getCurrentInstance();
Application app = facesContext.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = facesContext.getELContext();
ValueExpression valueExp =
 elFactory.createValueExpression(elContext, "#{bindings}", Object.class);
DCBindingContainer binding= (DCBindingContainer)valueExp.getValue(elContext);

 // Here you have to pass the VOIterator name and get the corresponding Iteratorbinding

DCIteratorBinding itrBinding=binding.findIteratorBinding("LoactionPoolViewIterator")
Row row =itrBinding.getCurrentRow();
}

No comments:

Post a Comment