Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How - to launch print dialog when showing printable page in Oracle ADF

2817992Jun 22 2015 — edited Jun 29 2015

Hello I am developing an ADF Web application. In this I have test.jsf page and a showPrintablePage behaviour command button. When user click the button adf just shows a printable page in new window. But when the user clicks on the button it should directly show in print window of browser. For this I got the following code from ADF Code Corner.

public void beforePhaseMethod(PhaseEvent phaseEvent)

{

if (phaseEvent.getPhaseId() == PhaseId.RENDER_RESPONSE) {

FacesContext fctx = FacesContext.getCurrentInstance();

AdfFacesContext adfFacesContext = AdfFacesContext.getCurrentInstance();

if (adfFacesContext.getOutputMode() == OutputMode.PRINTABLE) {

ExtendedRenderKitService erks = null; erks = Service.getRenderKitService(fctx, ExtendedRenderKitService.class); erks.addScript(fctx, "window.print();");

}

}

}

I have follwed the process specified in the document. And the follwoing is the test.jsf page code.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page contentType="text/html;charset=UTF-8"%> <%@ taglib uri="http://xmlns.oracle.com/adf/faces/rich" prefix="af"%>

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <f:view beforePhase="#{viewScope.PieBean.beforePhaseMethod}">

<af:document title="printTest" id="d1">

<af:form id="f1">

<af:commandButton text="commandButton 1" id="cb1">

<af:showPrintablePageBehavior/>

</af:commandButton>

<af:goButton text="goButton 1" id="gb1"/>

</af:form> </af:document>

</f:view>

but it is showing in test.jsf property inspector beforePhaseMethod is an unknown property.

And the final out is as follows

printOP.png

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 27 2015
Added on Jun 22 2015
27 comments
2,271 views