Showing posts with label adf. Show all posts
Showing posts with label adf. Show all posts

Wednesday, July 28, 2010

Invoking Method Binding Programmatically

The following code snippet can be used to invoke a method binding programmatically from java:

public void invokeMB(String mBinding){
    FacesContext fctx = FacesContext.getCurrentInstance();
    ExpressionFactory ef = fctx.getApplication().getExpressionFactory();
    ELContext elCtx = fctx.getELContext();
    ValueExpression valueExp = ef.createValueExpression(elCtx,"#{bindings}",Object.class);
    JUFormBinding a = (JUFormBinding)valueExp.getValue(elCtx);
    OperationBinding op = (OperationBinding)a.getOperationBinding(mBinding);
    op.execute();
}

Invoking Web Services in Oracle ADF

There are two ways to invoke a Web Service in an ADF Application:
1. JAX-WS Proxy
2. Web Service Data Control

JAX-WS Proxy
Just by providing the wsdl to the Create WebService Proxy wizard you can easily generate the proxy to invoke the webservice. More details on this can be found on my earlier post.
Pros:
Gives more flexibility and control to the WebService consumer. The developer can create webservice request object and can invoke the webservice as required. The proxy can also be wrapped as a DataControl (right click on the client java file and select Generate Data Control) and used in ADF.
Cons:
Maintanence is hard. Generates many files to support the proxy and the proxy has to be regenerated if the WSDL stucture changes.

Web Service Data Control
In the New Gallery select Web Service Data Control and provide the wsdl location in the wizard to generate the Data Control. Once the DataControl is generated it can be used on like any other datacontrol and the webservice's operations can be performed in ease. For eg, a button click on a page / method on taskflow.
Pros:
Easy to create and use.
Cons:
Limited control over invoking the webservice.

Wednesday, September 17, 2008

ADF: Calling JavaScript from a Managed Bean

I had a requirement of calling java script from a managed bean in ADF and this is how it can be implemented.


1 import javax.faces.context.FacesContext;
2 import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
3 import org.apache.myfaces.trinidad.util.Service;
4
5 public class InvokeRefresh {
6 public InvokeRefresh() {
7 }
8
9 public void invokeJS(){
10 FacesContext facesCtx = FacesContext.getCurrentInstance();
11 ExtendedRenderKitService service = Service.getRenderKitService(facesCtx,ExtendedRenderKitService.class);
12 service.addScript(facesCtx,"alert('Invoking JS from Managed Bean');");
13
14 }
15 }