Closing modal window causes exception

Hi,

I am new to vaadin and honestly to UI work in general. So please forgive my ignorance if this is a simple question.

I have been using the answer from this thread to try and close a modal window that is a subwindow:

http://vaadin.com/forum/-/message_boards/message/119574?_19_redirect=%2Fforum%2F-%2Fmessage_boards%2Fsearch%3F_19_redirect%3D%252Fforum%26_19_breadcrumbsCategoryId%3D0%26_19_searchCategoryIds%3D0%26_19_keywords%3Dsubwindow%2Brefresh%2Bmain%2Bwindow

My window gets the following exception when I try to close it:

java.lang.NoSuchMethodError: com.vaadin.ui.Window.getParent()Lcom/vaadin/ui/Window;
at org.dpportal.compliance.ui.form.ComplianceBaseLayout$2.buttonClick(ComplianceBaseLayout.java:53)

I am using vaadin with Liferay 6.0.4 and I do have a form that itself is not a window, instead I have a button on the main window that launches the form like this:

 Button newFormButton = new Button("New Incident", new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            // Just add component here and move the window creation to ComplianceBaseLayout
           Window formWindow = new Window();
            formWindow.addComponent(new ComplianceBaseLayout());
            formWindow.setName("FormWindow");
            formWindow.setHeight("380px");
            formWindow.setWidth("200px");
            formWindow.setModal(true);
            getWindow().addWindow(formWindow);
            
        }
    });

    addComponent(newFormButton);

And I then within ComplianceBaseLayout which extends VerticalLayout I have a Submit button with a click listener that tries to close the window like this:

Button apply = new Button(“Apply”, new Button.ClickListener() {
public void buttonClick(Button.ClickEvent event) {
try {
complianceForm.commit();
getWindow().getParent().removeWindow(getWindow());
} catch (Throwable e) {
// Ingnored, we’ll let the Form handle the errors later
e.printStackTrace();
}
}
});
buttons.addComponent(apply);

I am confused as the exception seems to indicate that I am using a version somewhere in classpath of Window that doesn’t have a getParent() method. As this is liferay I’ve wondered if there is an old copy of vaadin in classpath and tried to replace all copies I could find with my version of vaadin which is 6.4.1. I still repeatedly get this error. Can anyone shed some light on this for me?

Thanks in advance.

MiKey

Liferay 6 includes a version of Vaadin as well as the necessary resources (theme and widgetset), which must match the version of the Vaadin JAR used. The resources are served statically from /html/VAADIN, and the corresponding configuration parameters have been set in the portal configuration.

Normally, you would deploy your portlet without the Vaadin JAR, and let Liferay use the Vaadin version it has. You can do this by placing the Vaadin JAR ourside of WEB-INF/lib in your project, and adding it explicitly on the local (IDE) classpath for code completion etc.

If you do want to upgrade the Vaadin version on the portal, see e.g. the
instructions for Liferay 5.2 (scroll down to the 5.2 part, or also read the beginning)
- these steps have already been performed in Liferay 6, but you can replace the files to upgrade Vaadin on the portal.

Henri,

Thanks for the info. I did in fact validate that my portlet war does not include vaadin.jar. However when I deploy to liferay (cp mywar.war liferay-6.0.4/deploy) Liferay seems to add the jar to my portlets WEB-INF/lib itself.

Steps to confirm were to copy the war to a temporary location, unjar it, and look in WEB-INF/lib…there is no vaadin.jar and in fact as I’m using maven, the vaadin dependency is listed as such:

com.vaadin vaadin 6.4.1 provided

So it looks like liferay knows or decides to add the jar itself. And in fact if I remove the jar from the portlets WEB-INF/lib the portlet no longer works.

Does this seem like correct behavior to anyone who is/does use Liferay with Vaadin?

Also the portlet was working fine until I added the close of the sub-window as mentioned in my original message, it then gives the exception which seems to indicate I have a version of vaadin provided by liferay that does not contain getWindow().getParent().

Is that newer functionality than perhaps the version of vaadin found in Liferay 6.0.4?

Thanks again!

I have resolved the issue temporarily by moving the vaadin.jar from the 6.4.1 download into Liferay’s ROOT webapp’s WEB-INF/lib. This seems to be where it is pulling it from to place in my portlets WEB-INF/lib.

Is it known (I can’t find it) what version of Vaadin ships with Liferay 6.0.4? It would seem whatever version it is does not have Window.getParent() method within it.

I’m also concerned as I don’t know where/if any other portlets are using Vaadin and how my little “tuning” may have affected those.

Yes, liferay automatically copies its own version of the JAR to the deployment directory of the portlet, and this is normally required for the portlet to work. However, AFAIK it never cleans them up. As long as you don’t have version numbers as a part of the file name (e.g. the Vaadin JAR included in Liferay is just called vaadin.jar), this is usually not a problem, but if you deploy JARs with different names containing the same classes with your portlet, problems may occur because of this.

If I remember correctly, the version included in Liferay 6.0.4 is Vaadin 6.3.4. To manually upgrade it, you also need to update the themes and widgetset - the process is similar to setting up Vaadin for Liferay 5.2, except that the configuration settings are already configured elsewhere unless you need to override them. See e.g.
this wiki page
(especially the part about Liferay 5.2).

The signature of Window.getParent() has changed between Vaadin 6.3.4 and 6.4.1. The return type has been changed from Component to the more precise Window, taking advantage of Java covariant return types. When you compile against the more specific signature, the other version cannot be found.