How-to launch browser print dialog when showing printable page

1772 단어 browser
The following code, when referenced from the beforePhase property of the f:view component, automatically opens the browser print dialog if a page is rendered as printable. I did write about this topic in the OTN Harvest summary of January 2011. To this time however I used an internal flag, which doesn't feel right. The code used in this post only uses public APIs and thus is a solution that lasts.

The managed bean method is referenced from the f:view component as follows
...
With this listener and code, when the af:showPrintableBehavior tag is used on a command item to show a printable page, the browser print dialog is automatically opened. While the same code also works for page fragments, the f:view tag is only available for JSPX documents. In this case you either set the beforePhase method property on the JSPX document hosting the page fragment, or define a global phase listener (faces-config.xml) that then works for all pages in an application.
텍스트:http://blogs.oracle.com/jdevotnharvest/entry/how_to_launch_browser_print

좋은 웹페이지 즐겨찾기