Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print contents of ModalPanel

Tags:

jsf

richfaces

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

like image 355
En-Motion Avatar asked Oct 18 '10 11:10

En-Motion


1 Answers

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();
setTimeout(function(){
    WindowObject.focus();
    WindowObject.print();
    WindowObject.close();
},6000);
}

source: http://www.isolutionteam.co.uk/printing-contents-of-a-div-using-javascript/

like image 163
jmj Avatar answered Oct 01 '22 10:10

jmj