Is it possible to print just the contents of <rich:modalPanel
>?
views:
30answers:
1
+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
2010-10-18 11:20:10
Source: http://www.isolutionteam.co.uk/printing-contents-of-a-div-using-javascript/, even including those invalid quotes.
BalusC
2010-10-18 11:29:43
@BalusC yes. exactly :)
org.life.java
2010-10-18 11:31:12
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
2010-10-18 12:28:56
This is what I use: <h:graphicImage value="../images/Print.png" width="30" height="30" onclick="PrintContent();" />
En-Motion
2010-10-18 12:47:41
@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
2010-10-18 12:49:59
It opens the print page dialog fine, but as I said a blank page is printed which is incorrect
En-Motion
2010-10-18 12:59:10
@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
2010-10-18 13:00:10
@org.life.java - Thanks very much. All seems to be working now.
En-Motion
2010-10-19 16:14:03
@En-Motion If you have added anything special that is not listed here please let us know
org.life.java
2010-10-19 16:15:08