Friday, 7 January 2011

call oracle report from adf

I used an af:commandbutton to show my report in a new browser window. My button use this backing bean: 

package vuo.view.backing;

import java.io.IOException;

import java.net.URL;

import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;

import oracle.adf.model.BindingContext;
import vuo.view.backing.Generales;
import oracle.binding.BindingContainer;
import oracle.binding.OperationBinding;

import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
import org.apache.myfaces.trinidad.util.Service;

public class openReport {
   
    private String idError = "0";
    Object dError  = "Error al insertar los parámetros del reporte."    ;
    String errorDescription = "Error en la llamada al Informe VUO";
 
    public openReport() {
    }

    public BindingContainer getBindings() {
        return BindingContext.getCurrent().getCurrentBindingsEntry();
    }

    public String callPdf() {
       
       //first i call pl sql function        
        BindingContainer bindings = getBindings();
        OperationBinding operationBinding =
            bindings.getOperationBinding("callInsertaReportParam");
        Object result = operationBinding.execute();
        Generales generales=null;
       
        if (result.equals(idError)) {
          generales.mostrarError(errorDescription,dError);
        }
        else {
               String idReport = result.toString();
               //System.out.println("ID del REPORT: "+ result);
               String url = "https://serverdomain:port/reports/rwservlet?keyapp&pid="+idReport;
               openUrlInNewWindow(url);
        }
       
        return null;
    }
   
  public void openUrlInNewWindow(String url) {
  ExtendedRenderKitService erks =
  Service.getRenderKitService(FacesContext.getCurrentInstance(),
  ExtendedRenderKitService.class);
  StringBuilder strb = new StringBuilder("window.open('" + url + "');");
  erks.addScript(FacesContext.getCurrentInstance(), strb.toString());
  } 
}
 

1 comment:


  1. Thanks for sharing this great information I am impressed by the information that you have on this blog. Same as your blog i found another one Oracle Fusion Supply Chain Management Cloud . Actually, I was looking for the same information on internet for
    Oracle Fusion HCM Interview Questions and Answers and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject.

    ReplyDelete