It would be common requirement to invoke a application module method from the backing bean. Unless if it is really required then only advisable to write a separate method in backing bean to invoke application module method. Follow the below steps to achieve this
Step1 : Define the application module method in respective page definition as shown in below screen shot
- Expose the method that you invoke in client interface, Goto Page Definition bindings and add the method bindings as shown below
Step2: Write the below code in backing bean to invoke application module method
Alternative approach
import oracle.binding.OperationBinding;
/**
* This method returns the Operation Bindings based on given input opeation name
*/
public static OperationBinding getOperationBinding(String pOperationName) {
BindingContainer bc = BindingContext.getCurrent().getCurrentBindingsEntry();
return bc.getOperationBinding(pOperationName);
}
// Below is the code snippet to invoke above method
OperationBinding oBindings =
getOperationBinding("getEmployeeDetails");
// Pass Input parameters
oBindings.getParamsMap().put("empID", locRow.getDealerId());
oBindings.getParamsMap().put("empLocID",
locRow.getDealerLocationId());
oBindings.execute();
Step1 : Define the application module method in respective page definition as shown in below screen shot
- Expose the method that you invoke in client interface, Goto Page Definition bindings and add the method bindings as shown below
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.application.Application;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import oracle.binding.OperationBinding;
FacesContext facesContext = FacesContext.getCurrentInstance();
Application app = facesContext.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = facesContext.getELContext();
ValueExpression valueExp =
elFactory.createValueExpression(elContext, "#{bindings}", Object.class);
BindingContainer binding= (BindingContainer)valueExp.getValue(elContext);
OperationBinding operationBinding=binding.getOperationBinding("createCurrentCustomerRow");
// Set the Input parameters to the operation bindings as below
operationBinding.getParamsMap().put("pCustomerID", "100");
// Invoke the Application module method
operationBinding.execute();
// Get the result from operation bindings
Object obj =operationBinding.getResult();
Alternative approach
import oracle.binding.OperationBinding;
/**
* This method returns the Operation Bindings based on given input opeation name
*/
public static OperationBinding getOperationBinding(String pOperationName) {
BindingContainer bc = BindingContext.getCurrent().getCurrentBindingsEntry();
return bc.getOperationBinding(pOperationName);
}
// Below is the code snippet to invoke above method
OperationBinding oBindings =
getOperationBinding("getEmployeeDetails");
// Pass Input parameters
oBindings.getParamsMap().put("empID", locRow.getDealerId());
oBindings.getParamsMap().put("empLocID",
locRow.getDealerLocationId());
oBindings.execute();
Thanks :)
ReplyDeleteIt helped me thanks a lot, so nice of you, Keep posting ;) ;)
ReplyDeleteYou are welcome !!
ReplyDelete