更新时间:2022-02-17 22:51:20
as Mark already mentioned you can find jsf portlet examples (also with primefaces) here http://www.liferay.com/community/liferay-projects/liferay-faces/demos
在您的jsf portlet中,您可以通过以下方式获取用户对象(包含角色):
inside your jsf portlet you can get the user object (containing the roles) by this way:
public static User getCurrentUser(){
User u = null;
FacesContext fc = FacesContext.getCurrentInstance();
ExternalContext externalContext = fc.getExternalContext();
if (externalContext.getUserPrincipal() != null) {
Long id = Long.parseLong(externalContext.getUserPrincipal().getName());
try {
u = UserLocalServiceUtil.getUserById(id);
}
catch (Exception ex) {
LOG.error(ex.getMessage());
}
}
return u;
}