Web Services for Remote Portlets (WSRP) is a way to deploy a portlet in one portal, a producer, and use it in another, a consumer. This is done using a special WSRP portlet that relays the user input from a consumer to an actual portlet running in a producer. The Vaadin WSRP add-on gives you the ability to run Vaadin portlets as remote WSRP portlets. The basic WSRP architecture is illustrated in Figure 13.8, “WSRP Architecture”.
In this documentation, we give the instructions for Liferay, but the Vaadin WSRP add-on should work in any other portal or non-portal server that supports WSRP. If you use other portal software, please refer to its documentation for the relevant parts of WSRP configuration.
The add-on is licensed under the same Apache License 2.0 as the Vaadin Framework itself.
The Vaadin WSRP add-on is available as a JAR from the Vaadin Directory as well as from a Maven repository, as described in Chapter 15, Using Vaadin Add-ons. Vaadin 6.6.0 or later is required.
You need to install the Vaadin WSRP JAR at least in the producer portals. A consumer only needs the widget set, but no JARs related to your Vaadin portlet, not even the Vaadin JAR.
You should put the Vaadin WSRP JAR in the WEB-INF/lib
folder under the root context in the producer portal
server. The location of the root context depends on the server, for
example in Tomcat it is in webapps/ROOT
.
The Vaadin WSRP add-on contains a widget set, which you must compile into the Vaadin widget set installed in the portal. The widget set is needed in both the producer and consumer portals, but you do not need the WSRP JAR (or any other Vaadin JARs) in the consumer portal. You can avoid compiling the widget set by copying it (and the Vaadin themes) from the producer.
If you use Liferay, the easiest way to compile the widget set is to
use the Vaadin
Control Panel for Liferay add-on (also available from Vaadin
Directory). Its use is described in detail in Section 13.9, “Vaadin Control Panel for Liferay”. You can use the Control Panel to
upgrade Vaadin, if you need, then select the Vaadin
WSRP add-on, and compile the widget set. Once compiled in
the producer, you can copy the ROOT/html/VAADIN
folder to the corresponding folder in a consumer, or do the same
compilation in the consumer separately.
For other portals than Liferay, a simple manual way to compile the
widget set is to create a Vaadin project in Eclipse, add the WSRP JAR
and any other required JARs to the
WebContent/WEB-INF/lib
folder, and click the
button. You need the
Vaadin Plugin for Eclipse to do this.
A portlet needs some configuration to be used as a remote portlet.
You need to replace the regular Vaadin application portlet in your
project to a WSRP portlet. Edit the
WEB-INF/portlet.xml
file and change the line:
<portlet-class>com.vaadin.terminal.gwt.server.ApplicationPortlet2</portlet-class>
to the following:
<portlet-class>com.vaadin.addon.wsrp.WSRPApplicationPortlet</portlet-class>
Once you have installed and Vaadin WSRP JAR in the producer portal, compiled the widget set, and deployed your portlet, you can configure it as a producer.
In Liferay, you can configure a WSRP portlet in the Control Panel as follows.
Open the Control Panel as an administrator and select WSRP.
Open the Producers tab and click to create a new producer.
Select your portlet from the Available portlets and click the left-arrow to select it as current.
Give the producer a Name and click .
The producer portlet is shown in the list. You need to copy the URL shown in the list when creating a consumer portlet in the consumer portal.
In other portals than Liferay, follow the instructions for the portal software to set up a portlet as a producer.
Once you have configured a portlet as a producer in the producer portal, you can add it as a consumer portlet in a consumer portal. The consumer portlet is not a Vaadin portlet but a special WSRP portlet that relays the user input to the producer portlet in the other portal.
This requires that you have copied or compiled the widget set (and themes) in the consumer, as described earlier.
In Liferay, you first need to configure a WSRP consumer in the Control Panel as follows:
Open the Control Panel as an administrator and open the WSRP section.
Select the Consumers tab and click to create a new consumer. The configuration window is shown in Figure 13.10, “WSRP Consumer Configuration”.
Copy and paste the URL for the producer portlet from the producer portal configuration.
Give the consumer a Name and click .
In the consumer list, click
→ for the new consumer.In the Manage Portlets view, click .
Give the consumer portlet a Name, select the Remote Portlet, and click .
Go back to Liferay from the Control Panel by clicking
.In the page where you want to add the portlet, click
→ → .Your remote portlet should show up in the list. Click
to add it to the page. You need to reload the page for the portlet to show up.In other portals than Liferay, follow the instructions for the portal software to set up the portlet as a producer.
The Vaadin WSRP implementation assumes that the widget set is located
in /html/VAADIN
URL. If you need to change this
default to serve the VAADIN
resource directory
from some other URL, you have to extend the
WSRPApplicationPortlet
class and override the
getStaticFilesLocation()
method, which
normally returns "/html
". It should return the path
under which the VAADIN
directory is found.
If you extend the portlet class, you need to use your custom class in
portlet.xml
.