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 ?
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.
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)
public class PortletApplication extends Vaadin2Application implements PortletListener {
@Override
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
long
- PortletListener cannot be resolved to a type
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 .
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 …
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.
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.