Printing a modal window in liferay

Hi,

I have a liferay page with several portlets. I need to print the content of a Embedded Viewer Object in one of the portlets.

I tried opening a modal window and using the embedded viewer in that with a print button. But it always prints the entire liferay page not just the modal window.

In vaadin modal windows cannot be printed? What is is work around to fix this?

[b]
private void displayPopup(StreamResource resource) {
Window window = new Window();
((VerticalLayout) window.getContent()).setSizeFull();
window.setResizable(true);
window.setWidth(“75%”);
window.setHeight(“75%”);
window.center();
window.setModal(true);
window.addComponent(new Label(“”, Label.CONTENT_XHTML));
Embedded e = new Embedded();
e.setType(Embedded.TYPE_BROWSER);
e.setSource(resource);
window.addComponent(e);
getApplication().getMainWindow().addWindow(window);
}[/b

[quote=Reshmi YV]
I have a liferay page with several portlets. I need to print the content of a Embedded Viewer Object in one of the portlets.

I tried opening a modal window and using the embedded viewer in that with a print button. But it always prints the entire liferay page not just the modal window.

In vaadin modal windows cannot be printed? What is is work around to fix this?

[b]
private void displayPopup(StreamResource resource) {
Window window = new Window();
((VerticalLayout) window.getContent()).setSizeFull();
window.setResizable(true);
window.setWidth(“75%”);
window.setHeight(“75%”);
window.center();
window.setModal(true);
window.addComponent(new Label(“”, Label.CONTENT_XHTML));
Embedded e = new Embedded();
e.setType(Embedded.TYPE_BROWSER);
e.setSource(resource);
window.addComponent(e);
getApplication().getMainWindow().addWindow(window);
}
[/b[/quote]

Disclaimer: I have not tried these.

First do myframe.focus() and then myframe.print() on the iframe in the Embedded (not on the top level window) in your javascript. This might require setting an explicit debug ID for the Embedded to be able to find it in the javascript.

Alternatively, maybe some print CSS could help, although there might be several complications with this.

The print() method needs to be called inside the iframe (embedded content). The browser will print the (DOM) document/window that calls the print method (which is a native javascript method we can’t hook onto in Vaadin).

I tried using media screen and print on every style sheet in the custom theme we are using in liferay, but it did not work.

How do I get the iframe object refering to the iframe in the Embedded object?

[b]

public void setDebugId(String id)
Adds an unique id for component that get’s transferred to terminal for testing purposes. Keeping identifiers unique throughout the Application instance is on programmers responsibility

[/b]

Is it okay to use the debug id for a production code?