Foren

How to open pop from vaadin portlet?

thumbnail
L P Bharat, geändert vor 12 Jahren.

How to open pop from vaadin portlet?

Junior Member Beiträge: 39 Beitrittsdatum: 20.08.08 Neueste Beiträge
I have to open a popup window from vaadin portlet.
I am using the following code:
-----------------------------------------------------------------------------------------------
Window window = new Window("Window to Print");
window.addComponent(new Label("Say Hi"));
getApplication().addWindow(window);
getWindow().open(new ExternalResource(window.getURL()),
"_blank", 800, 400, // Width and height
Window.BORDER_NONE); // No decorations
window.executeJavaScript("print();");
// Close the window automatically after printing
window.executeJavaScript("self.close();");

-----------------------------------------------------------------------------------------------

This works well in case of vaadin application but fails if it is vaadin base portlet
as window.getURL() returns "null" in case of portlet.

Please Suggest.
thumbnail
David H Nebinger, geändert vor 12 Jahren.

RE: How to open pop from vaadin portlet?

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
Well you have to remember that a portlet doesn't have a url, and that's why window.getUrl() is going to fail.

So your problem is your resource that you're using for the content. Since open() takes a resource, you should manufacture the url to the resource (http://host/my-portlet/blah.html). Alternatively you can use a different type of resource (a ClassResource for a classpath resource or a Resource instance to feed content dynamically to be rendered).