Skip to content

Mis en ligne par admin - 22 février 2013 - Services Web, Web Applications

Liferay Portlet – FAQ

Why my buttons or actions or listener don’t work ?
The most frequent issue is that you forgot to put a form or wrote « form » instead of the « h:form » tag… :)

How to get the user ?
FacesContext fc = FacesContext.getCurrentInstance();
String userID = fc.getExternalContext().getRemoteUser();

How to get Portlet Preferences ?
PortletPreferences pref = JSFPortletUtil.getPortletPreferences(fc);

How to store Portlet Preferences per user
Keeping default Portlet Preferences policy:

PortletPreferences pref = JSFPortletUtil.getPortletPreferences(fc);
prefs.setValue("myConfig-"+userId, myUserVal);
prefs.store();

Or set the Preferences Policy to be « per user », in liferay-portlet.xml add (after icon):
<preferences-unique-per-layout>false</preferences-unique-per-layout>
    <preferences-owned-by-group>false</preferences-owned-by-group>

How to get the request ?
FacesContext.getCurrentInstance().getExternalContext().getRequest()

Articles similaires

Les articles suivants abordent des thèmes communs.

Commentaires

Partagez vos remarques.

Il n'y a pas de commentaires pour cet article.

Add a Comment

Fill in the form and submit.