23.12.2012 Views

ZK Developer's Guide

ZK Developer's Guide

ZK Developer's Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

org.zkoss.zkplus.hibernate.<br />

HibernateSessionContextListener<br />

<br />

<br />

The copies the sessionMap to the event thread's ThreadLocal<br />

variable whenever a new event thread is initiated. So whenever you call<br />

getCurrentSession() in Hibernate the same sessionMap is referenced.<br />

Pay attention of this issue and then Hibernate can be used as described in<br />

the Hibernate documentation.<br />

[ 133 ]<br />

Chapter 5<br />

JasperReport<br />

JasperReport is an open-source reporting engine. It can generate print-quality output<br />

like PDF, HTML, and RTF. Because there is no communication between the <strong>ZK</strong> layer<br />

and the JasperReport module the integration is quite easy. Just generate the reports<br />

(or graphs or PDFs) with JasperReport and show them with <strong>ZK</strong> tools. A graphic may<br />

be loaded dynamically or a PDF can be shown by opening the link.<br />

To use JasperReport use the Java Controller for a ZUL page and use statements like:<br />

jasperReport = JasperCompileManager.compileReport(<br />

"reports/zkbook_demo.jrxml");<br />

jasperPrint = JasperFillManager.fillReport(<br />

jasperReport, new HashMap(), new<br />

JREmptyDataSource());<br />

JasperExportManager.exportReportToPdfFile(<br />

jasperPrint, "reports/zkbook.pdf");<br />

There is nothing more to configure.<br />

<strong>ZK</strong> Mobile<br />

Mobile devices have become more and more popular. There are some tools in<br />

the market to create mobile websites. <strong>ZK</strong> also supports the mobile device market<br />

with a special <strong>ZK</strong> Mobile solution. This <strong>ZK</strong> Mobile client has to be installed into<br />

the mobile device and should be made to run as a thin client to interact with a <strong>ZK</strong><br />

server. However, the solution isn't perfect because the user has to install software<br />

on his or her device even if he or she wishes to access only a single website. But the<br />

installation process on mobile devices can be automated so it's not that big an issue.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!