DATE: Feb 23, 2010
AUTHOR: Jacopo Cappellato
In our last post of the tutorial series OFBiz Tutorial – Implementing a Product CSV export we have learned how to quickly implement a CSV export of a list of rows.
In this post we will perform similar steps in order to create a PDF version of the “Product List” screen.
PDF exports are supported out of the box by the OFBiz widgets.
In this exercise we will:
We have already learned how to create a link in a screen. We add it after the “CSV Export” link:
<container style="button-bar"> <link target="ProductListExport" text="CSV Export" style="buttontext"/> <link target="ProductListPDF" text="PDF Export" style="buttontext"/> </container>
<request-map uri="ProductListPDF"> <security https="true" auth="true"/> <response name="success" type="view" value="ProductListPDFScreen"/> </request-map> ... <view-map name="ProductListPDFScreen" type="screenfop" content-type="application/pdf" page="component://hwm/widget/HwmScreens.xml#ProductListPDF"/>
The entries are very similar to the ones we have implemented in a previous post for the product list screen. There are just a couple of things to notice:
There isn’t anything special in a screen definition for a PDF export; the screen is defined in the same way of a normal screen, except for a couple of details:
<screen name="ProductListPDF"> <section> <actions> <set field="viewSize" value="10000"/> <set field="pageLayoutName" value="main-page-landscape"/> <entity-condition entity-name="Product" list="products"> <order-by field-name="productId"/> </entity-condition> </actions> <widgets> <decorator-screen name="FoReportDecorator" location="component://common/widget/CommonScreens.xml"> <decorator-section name="body"> <container> <label text="Finished Products" style="h1"/> </container> <include-form name="ListProducts" location="component://hwm/widget/HwmForms.xml"/> </decorator-section> </decorator-screen> </widgets> </section> </screen>
The exercise is complete and we can test the product PDF by clicking the “PDF Export” link (there is no need to restart OFBiz).
Implementing the PDF report ended up being very similar to implementing the CSV export (or HTML screen): in OFBiz the same patterns, tools and languages can be reused to dramatically improve productivity.
– Jacopo