tags:

views:

30

answers:

1

Is it possible to print just the contents of <rich:modalPanel>?

+2  A: 

Wrap all the content of rich:modalpanel in a div then use following javascript snippet to do your work, of course it is not standard. add a print button in richmodal panel on click call this function of javascript

function PrintContent()
{
var DocumentContainer = document.getElementById('divtoprint');
var WindowObject = window.open("", "PrintWindow",
"width=750,height=650,top=50,left=50,toolbars=no,scrollbars=yes,status=no,resizable=yes");
WindowObject.document.writeln(DocumentContainer.innerHTML);
WindowObject.document.close();
WindowObject.focus();
WindowObject.print();
WindowObject.close();
}
org.life.java
Source: http://www.isolutionteam.co.uk/printing-contents-of-a-div-using-javascript/, even including those invalid quotes.
BalusC
@BalusC yes. exactly :)
org.life.java
OK, tried that code but when I click on my icon it opens a blank page for printing. However there is content in my modalpanel which it's not printing
En-Motion
This is what I use: <h:graphicImage value="../images/Print.png" width="30" height="30" onclick="PrintContent();" />
En-Motion
@En-Motion yes you can use this picture to represent printer button. BTW let me know once you get done with this
org.life.java
It opens the print page dialog fine, but as I said a blank page is printed which is incorrect
En-Motion
@En-MotionTry debugging, try to alert() content of DIV in which you have put all the data that is supposed to be printed, also check this http://www.dynamicdrive.com/forums/showthread.php?t=20162
org.life.java
@org.life.java - Thanks very much. All seems to be working now.
En-Motion
@En-Motion If you have added anything special that is not listed here please let us know
org.life.java