Wednesday, August 15, 2012

Declarative Component in Oracle ADF (To Generate the PDF/CSV/XML type of report)

Declarative Component in Oracle ADF (To Generate the PDF/CSV/XML type of report) :

Since adf faces does not have any component which help us to download the report (s) in to following format .

or might be other different format .(In  case if you know any other format please let me know )

In one of my application where we need to generate the reports in to pdf format therefore  we thought  to create the declarative components which will support us to generate the reports into pdf format and in this post i am going to explain the same .

Here i am not going to share how to create the declarative component. Although i would like to share the following link which is might be use full .


Above two link  will be give some grip on the jsf /adf  declarative  component  creation .

Please download following two jar to use the component which i has been created
First jar contains source of the component and second jar is itext pdf generation jar (which is open source)

First :
You can download the jar file using following link (declarative component jar location)

Second :
For download itext  jar :

Step to add the jar in project after that you can able to use in your project . 

1- download and put into local location .
2-Go to the Resource Palette  

3-Here we need to create the file system to access the jar file into the project.
4-Please follow the following pictorial step to create the file  system connection 

* exclude jar file name .For example if folder A contains jar then path should be A:\ 

Select the file system option and fill the above details .
5-Add the jar into the project .

Your jdeveloper is  ready to consume the declarative component .

Go to the component palette and in the drop down select the complib (i know here tag lib  name is not meaning full but in the next release(version) i will change the name with the appropriate name  )
image is following 

Till here it is common practice to consuming the declarative  component .see the following link if still you  have any confusion to how to use the declarative components

Declarative Component Specification(ReportDeclarative ) : 

Tag-Lib Name :compLib
Tag-Lib-URL: /componentLib
Tag-Lib-Prefix :report
Component Name :ReportDeclarative 

Attribute of the ReportDeclarative  component  are following  :

S.No. Attribute Name Required Explanation
1 Button Name Yes It will display as button name of download button
2 Report Name Yes Name of the does not require any extension 
3 Report Type Yes This version will support only pdf .So put PDF .if you  will give
other than this it will not work and also it not going to give any
error message (this feature will come in next version or release )
4 Table Id Yes af:table id which you want to export into pdf 

This version will support only the PDF report but in  the next version i will try to support the CSV and XML type of report.

Consideration point( Limitation ) :

1-Each column width will same .
2-Pdf width percentage is set to 100 %
3-Table Columns header will come as the pdf table columns.
4-Render false column will not going to shown on the pdf report
   same as af:exportCollectionActionListener components behavior
5-It is internally using the means here  i am using itext 5.1 version to generate the pdf .
6-Before going to use the component please download the same version of jar file of the itext and add into the project.
7-No exception handler implemented yet .It means if you are providing wrong table id or wrong report type it not going to give any type of message into the UI regardless you will able to download the file which will  corrupt.
8-Column width same regardless if one column contains less length of value to other column.
9-Need to test if you are using table inside  region or any other parent container.Because at run time client id changed based on parent id.
i.e.I tested  it using af:table with direct child with the af:form
sample code is following :--

<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="" version="2.1"
  < contentType="text/html;charset=UTF-8"/>
    <af:document id="d1">
      <af:messages id="m1"/>
      <report:reportDeclarative buttonName="Employee" reportType="PDF"
                                tableId="t1" id="rd1" reportName="sample"/>
      <af:form id="f1">
        <af:table value="#{bindings.ViewObj1.collectionModel}" var="row"
                  emptyText="#{bindings.ViewObj1.viewable ? 'No data to display.' : 'Access Denied.'}"
                  rowSelection="single" id="t1">
          <af:column sortProperty="EmployeeId" sortable="false"
                     id="c7" width="210">
            <af:outputText value="#{row.EmployeeId}" id="ot6">
              <af:convertNumber groupingUsed="false"
          <af:column sortProperty="FirstName" sortable="false"
                     id="c4" width="0">
            <af:outputText value="#{row.FirstName}" id="ot4"/>
          <af:column sortProperty="LastName" sortable="false"
                     id="c2" width="105">
            <af:outputText value="#{row.LastName}" id="ot5"/>
          <af:column sortProperty="Email" sortable="false"
                     headerText="#{bindings.ViewObj1.hints.Email.label}" id="c5"
            <af:outputText value="#{row.Email}" id="ot9"/>
          <af:column sortProperty="PhoneNumber" sortable="false"
                     id="c10" width="105">
            <af:outputText value="#{row.PhoneNumber}" id="ot7"/>
          <af:column sortProperty="HireDate" sortable="false"
                     id="c3" width="105">
            <af:outputText value="#{row.HireDate}" id="ot11">
              <af:convertDateTime pattern="#{bindings.ViewObj1.hints.HireDate.format}"/>
          <af:column sortProperty="JobId" sortable="false"
                     headerText="#{bindings.ViewObj1.hints.JobId.label}" id="c9"
            <af:outputText value="#{row.JobId}" id="ot3"/>
          <af:column sortProperty="Salary" sortable="false"
                     id="c1" width="105">
            <af:outputText value="#{row.Salary}" id="ot10">
              <af:convertNumber groupingUsed="false"
          <af:column sortProperty="CommissionPct" sortable="false"
                     id="c11" width="105">
            <af:outputText value="#{row.CommissionPct}" id="ot8">
              <af:convertNumber groupingUsed="false"
          <af:column sortProperty="ManagerId" sortable="false"
                     id="c8" width="105">
            <af:outputText value="#{row.ManagerId}" id="ot1">
              <af:convertNumber groupingUsed="false"
          <af:column sortProperty="DepartmentId" sortable="false"
                     id="c6" width="105">
            <af:outputText value="#{row.DepartmentId}" id="ot2">
              <af:convertNumber groupingUsed="false"

10-try to achieve same as  af:exportCollectionActionListener
11-Serial number need to add into the report.

New Feature(which will come into later release) :

1-XML report support.
2-CSV report support.
3-Exception handling (first we check whether report got successfully created or not.If not we will show the message into the pop up).
4-Source code
5-column width (column with come as same whatever is there in UI)
6-Need to change the tag lib name
7-Generate the report regardless the table structure .(no need to bother about where table will present )

At last i know here i did not explain internal functionality of the class which i have created but in next release sure i will share the source code as well.

Any suggestion would be appreciated.Any enhancement or any other feature which you want please share with me.
Please see this link for new declarative component



  1. Thank you.
    But I need more functionality in PDF reports like paging.
    Is there any solution to create reports like oracle report with only using ADF.

    Best Regards
    Amir , IRAN

  2. Hi IRAN,

    I do not know much about oracle report.Although you can customized report as based on your requirement.

    I agreed this component dose not have paging option.But in next version i would like to add the same.


  3. HY Prateek Kumar shaw
    Thank You for the post.
    But I am facing a problem

    When I place table inside any other parent container Pdf report is not generated. What I should do.

  4. it has limitation that is why i have posted one more post for same topic. please go to following link and download jar and try again


  5. Hi Prateek,
    Thanks for great post.It is really helpful.we would like to know is there is any other way to convert the whole page to PDF instead of af:table ?Please suggest

  6. Thanks Prateek ,

    It is really nice component.Can you please send me the code as well? As i need to include layout. Could you please help me on this?
    my email id is

    Thank you,

  7. Hey Thanks, Does it support pivotal table.

  8. No , Since both have different data model class.

  9. Hi,

    I am unable to download the jars. Can you please send me the source code with jars to my email id

  10. HI IRAN

    This jar file is not working in 12c Jdeveloper. I Tested in its working fine.

    Please upgrade jar file and publish or sent on my mail id :

  11. Hi Prateek ,

    Please Provide jar file that support in Jdev 12C

  12. Can u share that whole code please to mail id

  13. Hi
    Am unable to download two jar files which are mentioned in the above code
    Please help me to how to download jar files

    1. The Itext jar , you can download using itext website.
      download source code using following link

  14. is that can be use to build one for the form

  15. HI I am not able to download Application jar can you please send me jar at