Declarative Component in Oracle ADF (To Generate the PDF/CSV/XML type of report) :
1)PDF
2)HTML
3)XML
4)CSV
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 .
1-http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_40/jdtut_11r2_40.html
2-http://docs.oracle.com/cd/E17904_01/web.1111/b31973/af_reuse.htm#CHDDECDG
1-http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_40/jdtut_11r2_40.html
2-http://docs.oracle.com/cd/E17904_01/web.1111/b31973/af_reuse.htm#CHDDECDG
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 :
http://www.4shared.com/file/a8rSo6rk/itextpdf-510.html
http://www.4shared.com/file/a8rSo6rk/itextpdf-510.html
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 .
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 report.it 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 itextpdf-5.1.0.jar.it 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="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
xmlns:report="/componentLib">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<f:view>
<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"
rows="#{bindings.ViewObj1.rangeSize}"
emptyText="#{bindings.ViewObj1.viewable ? 'No data to display.' : 'Access Denied.'}"
fetchSize="#{bindings.ViewObj1.rangeSize}"
rowBandingInterval="0"
selectedRowKeys="#{bindings.ViewObj1.collectionModel.selectedRow}"
selectionListener="#{bindings.ViewObj1.collectionModel.makeCurrent}"
rowSelection="single" id="t1">
<af:column sortProperty="EmployeeId" sortable="false"
headerText="#{bindings.ViewObj1.hints.EmployeeId.label}"
id="c7" width="210">
<af:outputText value="#{row.EmployeeId}" id="ot6">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.ViewObj1.hints.EmployeeId.format}"/>
</af:outputText>
</af:column>
<af:column sortProperty="FirstName" sortable="false"
headerText="#{bindings.ViewObj1.hints.FirstName.label}"
id="c4" width="0">
<af:outputText value="#{row.FirstName}" id="ot4"/>
</af:column>
<af:column sortProperty="LastName" sortable="false"
headerText="#{bindings.ViewObj1.hints.LastName.label}"
id="c2" width="105">
<af:outputText value="#{row.LastName}" id="ot5"/>
</af:column>
<af:column sortProperty="Email" sortable="false"
headerText="#{bindings.ViewObj1.hints.Email.label}" id="c5"
width="105">
<af:outputText value="#{row.Email}" id="ot9"/>
</af:column>
<af:column sortProperty="PhoneNumber" sortable="false"
headerText="#{bindings.ViewObj1.hints.PhoneNumber.label}"
id="c10" width="105">
<af:outputText value="#{row.PhoneNumber}" id="ot7"/>
</af:column>
<af:column sortProperty="HireDate" sortable="false"
headerText="#{bindings.ViewObj1.hints.HireDate.label}"
id="c3" width="105">
<af:outputText value="#{row.HireDate}" id="ot11">
<af:convertDateTime pattern="#{bindings.ViewObj1.hints.HireDate.format}"/>
</af:outputText>
</af:column>
<af:column sortProperty="JobId" sortable="false"
headerText="#{bindings.ViewObj1.hints.JobId.label}" id="c9"
width="105">
<af:outputText value="#{row.JobId}" id="ot3"/>
</af:column>
<af:column sortProperty="Salary" sortable="false"
headerText="#{bindings.ViewObj1.hints.Salary.label}"
id="c1" width="105">
<af:outputText value="#{row.Salary}" id="ot10">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.ViewObj1.hints.Salary.format}"/>
</af:outputText>
</af:column>
<af:column sortProperty="CommissionPct" sortable="false"
headerText="#{bindings.ViewObj1.hints.CommissionPct.label}"
id="c11" width="105">
<af:outputText value="#{row.CommissionPct}" id="ot8">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.ViewObj1.hints.CommissionPct.format}"/>
</af:outputText>
</af:column>
<af:column sortProperty="ManagerId" sortable="false"
headerText="#{bindings.ViewObj1.hints.ManagerId.label}"
id="c8" width="105">
<af:outputText value="#{row.ManagerId}" id="ot1">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.ViewObj1.hints.ManagerId.format}"/>
</af:outputText>
</af:column>
<af:column sortProperty="DepartmentId" sortable="false"
headerText="#{bindings.ViewObj1.hints.DepartmentId.label}"
id="c6" width="105">
<af:outputText value="#{row.DepartmentId}" id="ot2">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.ViewObj1.hints.DepartmentId.format}"/>
</af:outputText>
</af:column>
</af:table>
</af:form>
</af:document>
</f:view>
</jsp:root>
10-try to achieve same as af:exportCollectionActionListener
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="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
xmlns:report="/componentLib">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<f:view>
<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"
rows="#{bindings.ViewObj1.rangeSize}"
emptyText="#{bindings.ViewObj1.viewable ? 'No data to display.' : 'Access Denied.'}"
fetchSize="#{bindings.ViewObj1.rangeSize}"
rowBandingInterval="0"
selectedRowKeys="#{bindings.ViewObj1.collectionModel.selectedRow}"
selectionListener="#{bindings.ViewObj1.collectionModel.makeCurrent}"
rowSelection="single" id="t1">
<af:column sortProperty="EmployeeId" sortable="false"
headerText="#{bindings.ViewObj1.hints.EmployeeId.label}"
id="c7" width="210">
<af:outputText value="#{row.EmployeeId}" id="ot6">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.ViewObj1.hints.EmployeeId.format}"/>
</af:outputText>
</af:column>
<af:column sortProperty="FirstName" sortable="false"
headerText="#{bindings.ViewObj1.hints.FirstName.label}"
id="c4" width="0">
<af:outputText value="#{row.FirstName}" id="ot4"/>
</af:column>
<af:column sortProperty="LastName" sortable="false"
headerText="#{bindings.ViewObj1.hints.LastName.label}"
id="c2" width="105">
<af:outputText value="#{row.LastName}" id="ot5"/>
</af:column>
<af:column sortProperty="Email" sortable="false"
headerText="#{bindings.ViewObj1.hints.Email.label}" id="c5"
width="105">
<af:outputText value="#{row.Email}" id="ot9"/>
</af:column>
<af:column sortProperty="PhoneNumber" sortable="false"
headerText="#{bindings.ViewObj1.hints.PhoneNumber.label}"
id="c10" width="105">
<af:outputText value="#{row.PhoneNumber}" id="ot7"/>
</af:column>
<af:column sortProperty="HireDate" sortable="false"
headerText="#{bindings.ViewObj1.hints.HireDate.label}"
id="c3" width="105">
<af:outputText value="#{row.HireDate}" id="ot11">
<af:convertDateTime pattern="#{bindings.ViewObj1.hints.HireDate.format}"/>
</af:outputText>
</af:column>
<af:column sortProperty="JobId" sortable="false"
headerText="#{bindings.ViewObj1.hints.JobId.label}" id="c9"
width="105">
<af:outputText value="#{row.JobId}" id="ot3"/>
</af:column>
<af:column sortProperty="Salary" sortable="false"
headerText="#{bindings.ViewObj1.hints.Salary.label}"
id="c1" width="105">
<af:outputText value="#{row.Salary}" id="ot10">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.ViewObj1.hints.Salary.format}"/>
</af:outputText>
</af:column>
<af:column sortProperty="CommissionPct" sortable="false"
headerText="#{bindings.ViewObj1.hints.CommissionPct.label}"
id="c11" width="105">
<af:outputText value="#{row.CommissionPct}" id="ot8">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.ViewObj1.hints.CommissionPct.format}"/>
</af:outputText>
</af:column>
<af:column sortProperty="ManagerId" sortable="false"
headerText="#{bindings.ViewObj1.hints.ManagerId.label}"
id="c8" width="105">
<af:outputText value="#{row.ManagerId}" id="ot1">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.ViewObj1.hints.ManagerId.format}"/>
</af:outputText>
</af:column>
<af:column sortProperty="DepartmentId" sortable="false"
headerText="#{bindings.ViewObj1.hints.DepartmentId.label}"
id="c6" width="105">
<af:outputText value="#{row.DepartmentId}" id="ot2">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.ViewObj1.hints.DepartmentId.format}"/>
</af:outputText>
</af:column>
</af:table>
</af:form>
</af:document>
</f:view>
</jsp:root>
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
http://adfwithejb.blogspot.in/2012/08/declarative-component-in-oracle-adf-to_28.html
Thanks
Prateek
Thank you.
ReplyDeleteBut 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
Hi IRAN,
ReplyDeleteI 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.
Thanks
Prateek
HY Prateek Kumar shaw
ReplyDeleteThank 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.
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
ReplyDeletehttp://adfwithejb.blogspot.in/2012/08/declarative-component-in-oracle-adf-to_28.html
Thank
Prateek
Hi Prateek,
ReplyDeleteThanks 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
Thanks Prateek ,
ReplyDeleteIt 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 narays3@gmail.com
Thank you,
narays3@gmail.com
Sreejith
Hey Thanks, Does it support pivotal table.
ReplyDeleteNo , Since both have different data model class.
ReplyDeleteHi,
ReplyDeleteI am unable to download the jars. Can you please send me the source code with jars to my email id srinim4@gmail.com
HI IRAN
ReplyDeleteThis jar file is not working in 12c Jdeveloper. I Tested in 11.1.2.3 its working fine.
Please upgrade jar file and publish or sent on my mail id : jatakia.vin@gmail.com
Hi Prateek ,
ReplyDeletePlease Provide jar file that support in Jdev 12C
Can u share that whole code please to mail id
ReplyDeletegouthamadf@gmail.com
Hi
ReplyDeleteAm unable to download two jar files which are mentioned in the above code
Please help me to how to download jar files
The Itext jar , you can download using itext website.
Deletedownload source code using following link
https://docs.google.com/file/d/0B8cP4jZuxLlXbWs2TjNwZzFvdGM/edit
is that can be use to build one for the form
ReplyDeleteHI I am not able to download Application jar can you please send me jar at amitdwivedi173@gmail.com
ReplyDelete