Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
book-of-vaadin.pdf
Скачиваний:
88
Добавлен:
24.03.2015
Размер:
13.43 Mб
Скачать

Portal Integration

portal-dependency-jars

The JAR libraries on which this portlet depends.This should have value vaadin.jar, unless you need to use a specific version. The JAR must be installed in the portal, for e x a m p l e , i n L i f e r a y b u n d l e d w i t h To m c a t t o tomcat-x.x.x/webapps/ROOT/WEB-INF/lib/vaadin.jar.

12.4. Portlet Hello World

The Hello World program that runs as a portlet is no different from a regular Vaadin application, as long as it doesn't need to handle portlet actions, mode changes, and so on.

import com.vaadin.Application; import com.vaadin.ui.*;

public class PortletExample extends Application { @Override

public void init() {

Window mainWindow = new Window("Portlet Example");

Label label = new Label("Hello Vaadin user"); mainWindow.addComponent(label); setMainWindow(mainWindow);

}

}

In addition to the application class, you need the descriptor files, libraries, and other files as described earlier. Figure 12.2, “Portlet Project Structure in Eclipse” shows the complete project structure under Eclipse.

Installed as a portlet in Liferay from the Add Application menu, the application will show as illustrated in Figure 12.3, “Hello World Portlet”.

Figure 12.3. Hello World Portlet

12.5. Installing Vaadin in Liferay

Loading widget sets, themes, and the Vaadin JAR from a portlet is possible as long as you have a single portlet, but causes a problem if you have multiple portlets. To solve this, Vaadin portlets need to use a globally installed widget set, themes, and Vaadin JAR. They, and all the required configuration, are bundled with Liferay 5.3 and later, but if you are using an earlier version of Liferay or use a custom widget set, custom themes, or a later version of Vaadin, you need to install them in Liferay.

Liferay 6.1, which is the latest Liferay version at the time of the publication of this book, comes with an older Vaadin 6 version. If you want to use Vaadin 7, you need to install it manually as described in this chapter.

Portlet Hello World

327

Portal Integration

Figure 12.2. Portlet Project Structure in Eclipse

In these instructions, we assume that you use Liferay bundled with Apache Tomcat, although you can use almost any other application server with Liferay just as well. The Tomcat installation is included in the Liferay installation package, under the tomcat-x.x.x directory.

12.5.1. Removing the Bundled Installation

Before installing a new Vaadin version, you need to remove the version bundled with Liferay. You need to remove the Vaadin library JAR from the library directory of the portal and the VAADIN directory from under the root context. For example, with Tomcat, they are usually located as follows:

tomcat-x.x.x/webapps/ROOT/html/VAADIN

tomcat-x.x.x/webapps/ROOT/WEB-INF/lib/vaadin.jar

12.5.2.Installing Vaadin

1.Get the Vaadin installation package from the Vaadin download page

2.Extract the following Vaadin JARs from the installation package: vaadin-server.jar and vaadin-shared.jar, as well as the vaadin-shared-deps.jar and jsoup.jar dependencies from the lib folder

3.Rename the JAR files as they were listed above, without the version number

328

Removing the Bundled Installation

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]