API Liferay in Vaadin Portlet

I’m testing Liferay portlets and Vaadin, I want to know how I can interact with Liferay Vaadin APIs, eg
to get the authenticated user name in the example code ? .I’m new to this Where I can get source code examples?
Related documentation ?

API liferay:

Example Code:

package com.example.vaadin1;

import com.vaadin.Application;
import com.vaadin.ui.;
import com.liferay.portal.
import com.liferay.portal.model.User;
import com.liferay.portlet.*;

public class Vaadin1Application extends Application {
public void init() {

String name;


name = User.getFullName();

	Window mainWindow = new Window("Vaadin1 Application");	
	Label label = new Label(name);   //User loged
	LoginFormExample x = new LoginFormExample();

import com.vaadin.ui.LoginForm;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.LoginForm.LoginEvent;

public class LoginFormExample extends VerticalLayout {

public LoginFormExample() {

    LoginForm login = new LoginForm();
    login.addListener(new LoginForm.LoginListener() {
        public void onLogin(LoginEvent event) {
                    "New Login",
                    "Username: " + event.getLoginParameter("username")
                            + ", password: "
                            + event.getLoginParameter("password"));



Eclipse Error message: Cannot make a static reference to the non-static method getFullName() from the type User

I’m a beginner and help is welcome


For getting Liferay user information, you need to store the user information in a listener when receiving a request, and access this temporarily stored value in your application. See e.g.
this thread
for an example.

I don’t see what you are trying to achieve with the login form in your example, on a portal you typically let the portal take care of authentication and then just ask the portal about the logged in user. I suppose you would put some other component there in the real application, not a login form.

You could also take a look at the chapter in the book about
Vaadin and portlet development

Thanks Henri: I have two questions

  1. I’ve a problem, because I used in the previous example a Servlet (default)
    Now I use in Eclipse → File → New → Vaadin Project :
    Project Name: Vaadin2
    Target Runtime: apache Tomcat V6.0
    Configuration : Default …
    Vaadin Deployment configuration:
    Generic Portlet (Portlet 2.0)

    Vaadin version: 6.4.0
    ----> Finish

    It create a Class Vaadin3Application correctly:

package com.example.vaadin2;

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

public class Vaadin2Application extends Application {
public void init() {
Window mainWindow = new Window(“Vaadin2 Application”);
Label label = new Label(“Hello Vaadin user”);


I get the Eclipse error: The import com.vaadin cannot be resolved

It’s possible, Vaadin version 6.4.0 is not download in Eclipse project ???
if I clik Download version show (as the last version = 6.3.1) ???

If I selected 6.3.1 portlet is correctly without error message …

What happens ??

  1. If I create a class PortletApplication like the example:

package com.example.vaadin2;

import com.liferay.portal.model.User;
import com.liferay.portal.util.PortalUtil;
import com.vaadin.Application;

public class PortletApplication extends Vaadin2Application implements PortletListener {

public void handleRenderRequest(RenderRequest request, RenderResponse response) {

User user = null;

try {
user = PortalUtil.getUser(request);
} catch (PortalException ex) {
// error handling
} catch (SystemException ex) {
// error handling

setUser(user); // the Vaadin Application USER to liferay's user. Gives your application easy access

// rest of your code

// rest of your application goes here

I get Multiple markers at this line:
- The serializable class PortletApplication does not declare a static final serialVersionUID field of type
- PortletListener cannot be resolved to a type

I feel my inexperience
Thanks !!

This is strange - maybe 6.4.0 was somehow not correctly downloaded to the project.
You could try changing the Vaadin version to an earlier one in the project properties, and then changing it back to 6.4.0 (letting Eclipse download it if it is not on the list). If that fails, you can also manually download the Vaadin JAR and put it on the project classpath.

On the other hand, if you have configured your Liferay as recommended for use with Vaadin (i.e. with shared resources and a shared Vaadin JAR), you should anyway move the Vaadin 6.4.0 JAR out of WEB-INF/lib - either into e.g. /lib under your project or outside the project. Then add a dependency to it in the Eclipse project “compile classpath” so that Eclipse finds the classes. This way, you don’t deploy redundant copies of the Vaadin JAR (which increases the deployment size and may lead to version conflicts when you upgrade one but not the other).

By default, the Portlet 2.0 project wizard downloads the Vaadin JAR into WEB-INF/lib as some users might not have set up the recommended configuration yet, and the wizard does not know where to find a portal installation with the Vaadin JAR. There is an enhancement request to let the user specify the location of a Liferay portal instead, and automatically make the project classpath point to a Vaadin JAR there rather than downloading one.

The first warning is harmless unless you need the classes to be serializable e.g. for some clustering software (or use on the Google AppEngine, but this does not concern portlets). You can let Eclipse generate a serialVersionUID if you want, tell Eclipse to ignore those warnings in your project or simply not pay attention to them.

The second is probably related to your imports. There are two different PortletListener interfaces in Vaadin, you have to point to the correct one, which for portlet 2.0 is PortletApplicationContext2.PortletListener .

Thanks Henri.

Perhaps the 6.4.0 version does not load well in eclipse.
Eclipse Java EE IDE for Web Developers.
Version: Helios Release
Build id: 20100617-1415

I downloaded vaadin-6.4.0.jar and I’ve manually installed on the project and functions well.

1.) Where I can find examples of code that interact with the portlets created with vaadin and Liferay ?
For example, available from vaadin portlet the number of users connected to Liferay, or internal data liferay that interested me at one point …


Hi Mauro,
look into this forum post:
How to get portlet preferences in init()?
Its probably what you are looking for.

I am curios if I can install newer Vaadin version into Liferay. I have Liferay 6.0.5 and its vaadin.jar is of version. 6.3.4 but I’d like to use some functionality available in newer version.

Is it possible?


Future versions of Liferay will probably use Vaadin 6.4.5 or later.

I have already written about this elsewhere on the forum, but:

To upgrade manually, you need to replace vaadin.jar in webapps/ROOT/WEB-INF/lib as well as the themes and widgetsets in webapps/ROOT/html/VAADIN - see
the instructions on how to install a shared copy of Vaadin in Liferay 5.2.x
. Note that the Vaadin configuration settings are pre-configured elsewhere in Liferay 6.x, but you can override them in portal-ext.properties if you want.

You might need to get the ZIP package of Vaadin and compile the widgetsets to get the necessary themes and widgetsets - if I recall correctly, not all of them are in the JAR file.