Some thoughts on Java Platform
Header image

Condition on printable page with af:showPrintablePageBehavior

Posted by raphaufrj in ADF

My use case is very simple. I have two pages, the first one has a couple of fields and the second one shows the result of these fields based on specific calculus.

The result page has a print button, which calls a new browser page that is ready to print.

In addition, I would like in this “new browser page” shows also the customer logo above the result, but only in printable page.

The code below shows how I can achieve this requirement:


<af:panelStretchLayout id="psl1" >

 <f:facet name="top">

 <af:panelGroupLayout id="pgl6" halign="center" layout="scroll"
 styleClass="AFStretchWidth">
 <af:image source="/images/logo.gif" shortDesc="logo" rendered="<strong>#{adfFacesContext.outputMode eq 'printable'}</strong>"
 id="i1" />
 </af:panelGroupLayout>

 </f:facet>

 <f:facet name="center">

<af:panelBox id="pcg7"
 text="Result">

<af:panelGroupLayout layout="horizontal"
 id="pgl5"
 halign="right"
 styleClass="AFStretchWidth">
 <af:commandLink id="cl1">
 <af:image shortDesc="Imprimir" source="/images/bt_imprimir.gif" inlineStyle="border:none" id="image2"/>
 <af:showPrintablePageBehavior />
 </af:commandLink>
 </af:panelGroupLayout>

</af:panelBox>
 </f:facet>
 </af:panelStretchLayout>

 

The secret was the rendered property: #{adfFacesContext.outputMode eq ‘printable’}. That is it!

You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>