A SPECIAL REPORT
Reporting solutions for ADF Applications




Luc Bors
Oracle Certified ADF Implementation Specialist

AMIS Services, The Netherlands
Oracle ADF Specialized Partner


Monday, June 25, 2012
ODTUG KScope 12
San Antonio, Texas, USA
REPORTING
I USE ADF, WHAT ABOUT REPORTS ?
ORACLE REPORTS DEVELOPER
CREATING ORACLE REPORTS

•   Example:

    – Employees per Department Report

    – Parameter P_DEPARTMENT_ID
HOW TO CALL THE REPORT ?
USING ORACLE REPORTS

•   Use Case : Invoke the report for the currently selected
    Department in an ADF table
PREPARING THE CALL

           •   Create a bean and method to invoke the report

<managed-bean id="__13">
   <managed-bean-name id="__14">oracleReportBean</managed-bean-name>
   <managed-bean-class id="__15">
              com.blogspot.lucbors.reporting.view.orarep.OracleReportBean
   </managed-bean-class>
   <managed-bean-scope id="__16">request</managed-bean-scope>
 </managed-bean>




           •   Provide report parameters

String   oraReportServerUrl = "http://192.168.2.8:8889/reports/rwservlet?";
String   reportNameParam ="report=";
String   reportDestypeParam = "destype=";
String   reportPDesformatParam = "desformat=";
String   reportUseridParam = "userid=“;
CONSTRUCTING THE CALL

               •   Construct Report Server URL; Including the parameters
public void runOracleReport(ActionEvent actionEvent) {

     String departmentParam = "p_department_id=";

      StringBuffer totalCallUrl = new StringBuffer();
      totalCallUrl.append(getOraReportServerUrl());
      totalCallUrl.append(getReportNameParam().concat("employees.rdf")+"&");
      totalCallUrl.append(getReportDestypeParam().concat("cache")+"&");
      totalCallUrl.append(getReportPDesformatParam().concat("html")+"&");
      totalCallUrl.append(getReportUseridParam().concat("hr/hr@xe")+"&");
      totalCallUrl.append(departmentParam.concat(getDepartmentId()));

        setOraReportUrl(totalCallUrl.toString());
}


    public String getDepartmentId() {
      DCIteratorBinding it = ADFUtils.findIterator("SalaryOverview1Iterator");
      oracle.jbo.domain.Number deptId =
         (oracle.jbo.domain.Number)it.getCurrentRow().getAttribute("DepartmentId");
      return deptId.toString();
        }
CALL AND SHOW THE REPORT

            •   Call ………

<af:commandToolbarButton text="Run Oracle Report" id="cb3“
                actionListener="#{oracleReportBean.runOracleReport}">
       <af:showPopupBehavior popupId=":::showOraRpt" triggerType="click"/>
</af:commandToolbarButton>




            •   ……. And Show the report

<af:popup id="showOraRpt" animate="default">
          <af:panelWindow id="pw3" modal="true"
                          title="External Internet Info in a Modal Popup"
                          contentHeight="625" contentWidth="700" resize="on">
            <af:inlineFrame id="if3" shortDesc="This is an inline frame"
                            source="#{oracleReportBean.oraReportUrl}"
                            styleClass="AFStretchWidth"
                            inlineStyle="height:600px;">
            </af:inlineFrame>
</af:panelWindow>
SHOWING THE ORACLE REPORT

•   ….. and the result…..
CAN I USE FMW REPORTING TOOLS ?
ORACLE BI PUBLISHER
ORACLE BI PUBLISHER
ORACLE BI PUBLISHER
ORACLE BI PUBLISHER
PREPARING THE CALL

           •   Create a bean and method to invoke the report

 <managed-bean id="__13">
    <managed-bean-name id="__14">biPublisherBean</managed-bean-name>
    <managed-bean-class id="__15">
               com.blogspot.lucbors.reporting.view.orarep.BiPublisherBean
    </managed-bean-class>
    <managed-bean-scope id="__16">request</managed-bean-scope>
  </managed-bean>




           •   Provide report parameters

private static final String RAPPORT_SERVER_HOST_PARAM =
                     "http://192.168.56.101:7001/xmlpserver/~weblogic/";
private static final String RAPPORT_GENERAL_USER_PARAM = "<UN>";
private static final String RAPPORT_GENERAL_PASSWORD_PARAM = "<PW>";
CONSTRUCTING THE CALL

            •   Construct Report Server URL; Including the parameters
 public void startBiReport(ActionEvent event)
     {
       StringBuffer reportUrl = new StringBuffer();
       reportUrl.append(getRapportServerHost());
       reportUrl.append("/"+"EmployeesPerDepartment"+".xdo");
       // add standard params
       addStandardParams(rapport,reportUrl);
       // add report-specific params
       addReportParams(rapport, reportUrl);
       sLog.fine("Rapport start URL: "+reportUrl);
       setReportUrl(reportUrl.toString());
……..
CALL AND SHOW THE REPORT

            •   Call ………

<af:commandToolbarButton text="Run BI Publisher Report" id="cb3“
                actionListener="#{oracleReportBean.startBiReport}">
       <af:showPopupBehavior popupId=":::showBiRpt" triggerType="click"/>
</af:commandToolbarButton>




            •   ……. And Show the report

<af:popup id="showBiRpt" animate="default">
          <af:panelWindow id="pw3" modal="true"
                          title="External Internet Info in a Modal Popup"
                          contentHeight="625" contentWidth="700" resize="on">
            <af:inlineFrame id="if3" shortDesc="This is an inline frame"
                            source="#{<…BI report source>}"
                            styleClass="AFStretchWidth"
                            inlineStyle="height:600px;">
            </af:inlineFrame>
</af:panelWindow>
SHOWING THE BI PUBLISHER REPORT
ARE THERE OPEN SOURCE TOOLS ?
JASPER REPORTS
JASPER REPORTS - IREPORT
JASPER REPORT QUERY
CREATING JASPER REPORTS

•   Jasper  iReport as design tool
     – Select a report template
     – Create a new report based on a query




     – Add parameters
     – Test report in iReport
PREPARING JDEVELOPER AND ADF

•   Make sure to add Jasper libraries to ADF project
PREPARING THE CALL

         •   Create a bean and method to invoke the report

<managed-bean id="__13">
   <managed-bean-name id="__14">jasperReportBean</managed-bean-name>
   <managed-bean-class id="__15">
              com.blogspot.lucbors.reporting.view.orarep.JasperReportBean
   </managed-bean-class>
   <managed-bean-scope id="__16">request</managed-bean-scope>
 </managed-bean>
CALLING THE JASPER REPORT

         •   How to invoke the Jasper report ?
              – Get a handle to your template

 InputStream is = new FileInputStream (
        new File("C:/ReportingTools/myReports/MyFirstReport.jrxml"));

              – Define the file that will hold the generated report


OutputStream os=new FileOutputStream(
                        new File(this.filepath+this.reportname));

              – Optionally fill parameters


 Map parameters = new HashMap();
         parameters.put("P_DEPARTMENT_ID", getDepartmentId());
CALL AND SHOW THE REPORT

            •   Call ………

<af:commandToolbarButton text="Run Oracle Report" id="cb3“
                actionListener="#{oracleReportBean.runOracleReport}">
       <af:showPopupBehavior popupId=":::showOraRpt" triggerType="click"/>
</af:commandToolbarButton>
JASPER REPORTING

       •   Invoke the report ………
JasperDesign jasperDesign = JRXmlLoader.load(is);
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

JasperPrint jasperPrint =
                JasperFillManager.fillReport(jasperReport, parameters, conn);

JasperExportManager.exportReportToPdfStream(jasperPrint, os);




       •   ……. And Show the result


  JasperViewer.viewReport(jasperPrint, false);
JASPER REPORTING

•   ….. And the result….
I DONT WANT MY OWN REPORTSERVER
REPORTING FROM THE CLOUD
DOCMOSIS REPORTING
CREATING TEMPLATES
UPLOAD TO THE CLOUD
CALLING THE CLOUD FROM ADF

•   Setup a connection

•   Build the request

•   Write request to outputstream
PREPARING THE CALL

           •   Create a bean and method to invoke the report

 <managed-bean id="__13">
    <managed-bean-name id="__14">docmosisReportBean</managed-bean-name>
    <managed-bean-class id="__15">
               com.blogspot.lucbors.reporting.view.docmosis.DocmosisReportBean
    </managed-bean-class>
    <managed-bean-scope id="__16">request</managed-bean-scope>
  </managed-bean>




           •   Provide report parameters

private static final String DWS_RENDER_URL =
                   "https://dws.docmosis.com/services/rs/render";
private static final String ACCESS_KEY = “<your acces key>";
private static final String OUTPUT_FORMAT = "pdf";
private static final String OUTPUT_FILE = "myWelcome." + OUTPUT_FORMAT;
CONSTRUCTING THE CALL

           •   Construct Report Server URL; Including the parameters
private static String buildRequestForEmployee() {
       // the name of the template in our cloud account we want to use
       String templateName = "/KScopeDemoTemplate.doc";

       StringBuilder sb = new StringBuilder();

       // Start building the instruction
       sb.append("<?xml version="1.0" encoding="utf-8"?>");
       sb.append("<render n");
       sb.append("accessKey="").append(ACCESS_KEY).append("" ");
       sb.append("templateName="").append(templateName).append("" ");
       sb.append("outputName="").append(OUTPUT_FILE).append("">n");
CONSTRUCTING THE CALL

           •   Adding the Data

// now add the data specifically for this template
       sb.append("<datan");
       sb.append(" date="").append(new Date()).append(""n");
       sb.append(" title="Creating documents with Docmosis from ADF ">n");
       String[] messages = {
         "Reporting from ADF Applications - What are the Options? John Flack",
         "ADF Data Visualization Tips & Techniques. Chris Muir",
         "How to Bring Common UI Patterns to ADF. Luc Bors",
         "and many many more......"};
     for (int i = 0; i < messages.length; i++) {
       sb.append("<suggestions msg="").append(messages[i]).append(""/>n");
       }

       sb.append("</data>n");
       sb.append("</render>n");
CALL AND SHOW THE REPORT

            •   Call ………

 <af:commandToolbarButton text="Run docmosis Report" id="cb5"
                      actionListener="#{docmosisReportBean.runDocmosisReport}">
       <af:showPopupBehavior popupId=":::showDocmosisReport"
                             triggerType="action"/>
</af:commandToolbarButton>



            •   ……. And Show the report

 <af:popup id="showDocmosisReport" animate="default">
     <af:panelWindow id="pw2" modal="true" title="The report"
                     contentHeight="625" contentWidth="700" resize="on">
       <af:inlineFrame id="if2" shortDesc="This is an inline frame“
         source="/showpdfservlet?name=#{docmosisReportBean.docmosisreportname}"
         styleClass="AFStretchWidth"
         inlineStyle="height:600px;"></af:inlineFrame>
     </af:panelWindow>
</af:popup>
SHOWING THE RESULT
REPORTING; YOUR OPTIONS
COMMON FEATURES
PRO’S AND CON’S ?
ARE THERE OTHER ALTERNATIVES?
MORE REPORTING IN THE FMW TRACK
RESOURCES

•   OTN – Reports :
    http://www.oracle.com/technetwork/middleware/reports/overvie
    w/index.html

•   OTN – BI Publisher :
    http://www.oracle.com/technetwork/middleware/bi-
    publisher/overview/index.html

•   Jasper : http://jasperforge.org/projects/jasperreports

•   Docmosis : https://www.docmosis.com/

•   OS Reporting overview : http://java-source.net/open-
    source/charting-and-reporting

•   AMIS tech blog : http://technology.amis.nl

•   ADF-EMG site : http://groups.google.com/group/adf-
    methodology/web/adf-reporting?pli=1
A SPECIAL REPORT
Reporting solutions for ADF Applications




Luc Bors
Oracle Certified ADF Implementation Specialist

AMIS Services, The Netherlands
Oracle ADF Specialized Partner


Monday, June 25, 2012
ODTUG KScope 12
San Antonio, Texas, USA

Reporting solutions for ADF Applications

  • 1.
    A SPECIAL REPORT Reportingsolutions for ADF Applications Luc Bors Oracle Certified ADF Implementation Specialist AMIS Services, The Netherlands Oracle ADF Specialized Partner Monday, June 25, 2012 ODTUG KScope 12 San Antonio, Texas, USA
  • 2.
  • 3.
    I USE ADF,WHAT ABOUT REPORTS ?
  • 4.
  • 5.
    CREATING ORACLE REPORTS • Example: – Employees per Department Report – Parameter P_DEPARTMENT_ID
  • 6.
    HOW TO CALLTHE REPORT ?
  • 7.
    USING ORACLE REPORTS • Use Case : Invoke the report for the currently selected Department in an ADF table
  • 8.
    PREPARING THE CALL • Create a bean and method to invoke the report <managed-bean id="__13"> <managed-bean-name id="__14">oracleReportBean</managed-bean-name> <managed-bean-class id="__15"> com.blogspot.lucbors.reporting.view.orarep.OracleReportBean </managed-bean-class> <managed-bean-scope id="__16">request</managed-bean-scope> </managed-bean> • Provide report parameters String oraReportServerUrl = "http://192.168.2.8:8889/reports/rwservlet?"; String reportNameParam ="report="; String reportDestypeParam = "destype="; String reportPDesformatParam = "desformat="; String reportUseridParam = "userid=“;
  • 9.
    CONSTRUCTING THE CALL • Construct Report Server URL; Including the parameters public void runOracleReport(ActionEvent actionEvent) { String departmentParam = "p_department_id="; StringBuffer totalCallUrl = new StringBuffer(); totalCallUrl.append(getOraReportServerUrl()); totalCallUrl.append(getReportNameParam().concat("employees.rdf")+"&"); totalCallUrl.append(getReportDestypeParam().concat("cache")+"&"); totalCallUrl.append(getReportPDesformatParam().concat("html")+"&"); totalCallUrl.append(getReportUseridParam().concat("hr/hr@xe")+"&"); totalCallUrl.append(departmentParam.concat(getDepartmentId())); setOraReportUrl(totalCallUrl.toString()); } public String getDepartmentId() { DCIteratorBinding it = ADFUtils.findIterator("SalaryOverview1Iterator"); oracle.jbo.domain.Number deptId = (oracle.jbo.domain.Number)it.getCurrentRow().getAttribute("DepartmentId"); return deptId.toString(); }
  • 10.
    CALL AND SHOWTHE REPORT • Call ……… <af:commandToolbarButton text="Run Oracle Report" id="cb3“ actionListener="#{oracleReportBean.runOracleReport}"> <af:showPopupBehavior popupId=":::showOraRpt" triggerType="click"/> </af:commandToolbarButton> • ……. And Show the report <af:popup id="showOraRpt" animate="default"> <af:panelWindow id="pw3" modal="true" title="External Internet Info in a Modal Popup" contentHeight="625" contentWidth="700" resize="on"> <af:inlineFrame id="if3" shortDesc="This is an inline frame" source="#{oracleReportBean.oraReportUrl}" styleClass="AFStretchWidth" inlineStyle="height:600px;"> </af:inlineFrame> </af:panelWindow>
  • 11.
    SHOWING THE ORACLEREPORT • ….. and the result…..
  • 12.
    CAN I USEFMW REPORTING TOOLS ?
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
    PREPARING THE CALL • Create a bean and method to invoke the report <managed-bean id="__13"> <managed-bean-name id="__14">biPublisherBean</managed-bean-name> <managed-bean-class id="__15"> com.blogspot.lucbors.reporting.view.orarep.BiPublisherBean </managed-bean-class> <managed-bean-scope id="__16">request</managed-bean-scope> </managed-bean> • Provide report parameters private static final String RAPPORT_SERVER_HOST_PARAM = "http://192.168.56.101:7001/xmlpserver/~weblogic/"; private static final String RAPPORT_GENERAL_USER_PARAM = "<UN>"; private static final String RAPPORT_GENERAL_PASSWORD_PARAM = "<PW>";
  • 18.
    CONSTRUCTING THE CALL • Construct Report Server URL; Including the parameters public void startBiReport(ActionEvent event) { StringBuffer reportUrl = new StringBuffer(); reportUrl.append(getRapportServerHost()); reportUrl.append("/"+"EmployeesPerDepartment"+".xdo"); // add standard params addStandardParams(rapport,reportUrl); // add report-specific params addReportParams(rapport, reportUrl); sLog.fine("Rapport start URL: "+reportUrl); setReportUrl(reportUrl.toString()); ……..
  • 19.
    CALL AND SHOWTHE REPORT • Call ……… <af:commandToolbarButton text="Run BI Publisher Report" id="cb3“ actionListener="#{oracleReportBean.startBiReport}"> <af:showPopupBehavior popupId=":::showBiRpt" triggerType="click"/> </af:commandToolbarButton> • ……. And Show the report <af:popup id="showBiRpt" animate="default"> <af:panelWindow id="pw3" modal="true" title="External Internet Info in a Modal Popup" contentHeight="625" contentWidth="700" resize="on"> <af:inlineFrame id="if3" shortDesc="This is an inline frame" source="#{<…BI report source>}" styleClass="AFStretchWidth" inlineStyle="height:600px;"> </af:inlineFrame> </af:panelWindow>
  • 20.
    SHOWING THE BIPUBLISHER REPORT
  • 21.
    ARE THERE OPENSOURCE TOOLS ?
  • 22.
  • 23.
  • 24.
  • 25.
    CREATING JASPER REPORTS • Jasper  iReport as design tool – Select a report template – Create a new report based on a query – Add parameters – Test report in iReport
  • 26.
    PREPARING JDEVELOPER ANDADF • Make sure to add Jasper libraries to ADF project
  • 27.
    PREPARING THE CALL • Create a bean and method to invoke the report <managed-bean id="__13"> <managed-bean-name id="__14">jasperReportBean</managed-bean-name> <managed-bean-class id="__15"> com.blogspot.lucbors.reporting.view.orarep.JasperReportBean </managed-bean-class> <managed-bean-scope id="__16">request</managed-bean-scope> </managed-bean>
  • 28.
    CALLING THE JASPERREPORT • How to invoke the Jasper report ? – Get a handle to your template InputStream is = new FileInputStream ( new File("C:/ReportingTools/myReports/MyFirstReport.jrxml")); – Define the file that will hold the generated report OutputStream os=new FileOutputStream( new File(this.filepath+this.reportname)); – Optionally fill parameters Map parameters = new HashMap(); parameters.put("P_DEPARTMENT_ID", getDepartmentId());
  • 29.
    CALL AND SHOWTHE REPORT • Call ……… <af:commandToolbarButton text="Run Oracle Report" id="cb3“ actionListener="#{oracleReportBean.runOracleReport}"> <af:showPopupBehavior popupId=":::showOraRpt" triggerType="click"/> </af:commandToolbarButton>
  • 30.
    JASPER REPORTING • Invoke the report ……… JasperDesign jasperDesign = JRXmlLoader.load(is); JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn); JasperExportManager.exportReportToPdfStream(jasperPrint, os); • ……. And Show the result JasperViewer.viewReport(jasperPrint, false);
  • 31.
    JASPER REPORTING • ….. And the result….
  • 32.
    I DONT WANTMY OWN REPORTSERVER
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
    CALLING THE CLOUDFROM ADF • Setup a connection • Build the request • Write request to outputstream
  • 38.
    PREPARING THE CALL • Create a bean and method to invoke the report <managed-bean id="__13"> <managed-bean-name id="__14">docmosisReportBean</managed-bean-name> <managed-bean-class id="__15"> com.blogspot.lucbors.reporting.view.docmosis.DocmosisReportBean </managed-bean-class> <managed-bean-scope id="__16">request</managed-bean-scope> </managed-bean> • Provide report parameters private static final String DWS_RENDER_URL = "https://dws.docmosis.com/services/rs/render"; private static final String ACCESS_KEY = “<your acces key>"; private static final String OUTPUT_FORMAT = "pdf"; private static final String OUTPUT_FILE = "myWelcome." + OUTPUT_FORMAT;
  • 39.
    CONSTRUCTING THE CALL • Construct Report Server URL; Including the parameters private static String buildRequestForEmployee() { // the name of the template in our cloud account we want to use String templateName = "/KScopeDemoTemplate.doc"; StringBuilder sb = new StringBuilder(); // Start building the instruction sb.append("<?xml version="1.0" encoding="utf-8"?>"); sb.append("<render n"); sb.append("accessKey="").append(ACCESS_KEY).append("" "); sb.append("templateName="").append(templateName).append("" "); sb.append("outputName="").append(OUTPUT_FILE).append("">n");
  • 40.
    CONSTRUCTING THE CALL • Adding the Data // now add the data specifically for this template sb.append("<datan"); sb.append(" date="").append(new Date()).append(""n"); sb.append(" title="Creating documents with Docmosis from ADF ">n"); String[] messages = { "Reporting from ADF Applications - What are the Options? John Flack", "ADF Data Visualization Tips & Techniques. Chris Muir", "How to Bring Common UI Patterns to ADF. Luc Bors", "and many many more......"}; for (int i = 0; i < messages.length; i++) { sb.append("<suggestions msg="").append(messages[i]).append(""/>n"); } sb.append("</data>n"); sb.append("</render>n");
  • 41.
    CALL AND SHOWTHE REPORT • Call ……… <af:commandToolbarButton text="Run docmosis Report" id="cb5" actionListener="#{docmosisReportBean.runDocmosisReport}"> <af:showPopupBehavior popupId=":::showDocmosisReport" triggerType="action"/> </af:commandToolbarButton> • ……. And Show the report <af:popup id="showDocmosisReport" animate="default"> <af:panelWindow id="pw2" modal="true" title="The report" contentHeight="625" contentWidth="700" resize="on"> <af:inlineFrame id="if2" shortDesc="This is an inline frame“ source="/showpdfservlet?name=#{docmosisReportBean.docmosisreportname}" styleClass="AFStretchWidth" inlineStyle="height:600px;"></af:inlineFrame> </af:panelWindow> </af:popup>
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
    ARE THERE OTHERALTERNATIVES?
  • 47.
    MORE REPORTING INTHE FMW TRACK
  • 48.
    RESOURCES • OTN – Reports : http://www.oracle.com/technetwork/middleware/reports/overvie w/index.html • OTN – BI Publisher : http://www.oracle.com/technetwork/middleware/bi- publisher/overview/index.html • Jasper : http://jasperforge.org/projects/jasperreports • Docmosis : https://www.docmosis.com/ • OS Reporting overview : http://java-source.net/open- source/charting-and-reporting • AMIS tech blog : http://technology.amis.nl • ADF-EMG site : http://groups.google.com/group/adf- methodology/web/adf-reporting?pli=1
  • 49.
    A SPECIAL REPORT Reportingsolutions for ADF Applications Luc Bors Oracle Certified ADF Implementation Specialist AMIS Services, The Netherlands Oracle ADF Specialized Partner Monday, June 25, 2012 ODTUG KScope 12 San Antonio, Texas, USA