Portals such as Liferay are not AJAX applications but reload the page every time a user interaction requires data from the server. They consider a Vaadin application to be a regular web application that works by HTTP requests. All the AJAX communications required by the Vaadin application are done by the Vaadin Client-Side Engine (the widget set) past the portal, so that the portal is unaware of the communications.

The only way a portal can interact with an application is to load it with a HTTP request; reloading does not reset the application. The Portlet 2.0 API supports four types of requests: render, action, resource, and event requests. The old Portlet 1.0 API supports only the render and action requests. Requests can be caused by user interaction with the portal controls or by clicking action URLs displayed by the portlet. You can handle portlet requests by implementing the PortletListener interface and the handler methods for each of the request types. You can use the request object passed to the handler to access certain portal data, such as user information, the portlet mode, etc.

The PortletListener interface is defined in the PortletApplicationContext2 for Portlet 2.0 API and com.vaadin.terminal.gwt.server.PortletApplicationContext class for the old Portlet 1.0 API. You can get the portlet application context with getContext() method of the application class.

You need to have the portlet.jar in your class path during development. However, you must not deploy the portlet.jar with the portlet, because it would create a conflict with the internal portlet library of the portal. You should put it in a directory that is not deployed with the portlet, for example, if you are using Eclipse, under the lib directory under the project root, not under WebContent/WEB-INF/lib, for example.

You can also define portal actions that you can handle in the handleActionRequest() method of the interface.

You add your portlet request listener to the application context of your application, which is a PortletApplicationContext when (and only when) the application is being run as a portlet.

// Check that we are running as a portlet.
if (getContext() instanceof PortletApplicationContext2) {
    PortletApplicationContext2 ctx =
            (PortletApplicationContext2) getContext();

    // Add a custom listener to handle action and
    // render requests.
    ctx.addPortletListener(this, new MyPortletListener());
} else {
    getMainWindow().showNotification(
            "Not initialized via Portal!",
            Notification.TYPE_ERROR_MESSAGE);
}

The handler methods receive references to request and response objects, which are defined in the Java Servlet API. Please refer to the Servlet API documentation for further details.

The PortletDemo application included in the demo WAR package includes examples of processing mode and portlet window state changes in a portlet request listener.