且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将Jsf应用程序集成到Liferay中

更新时间:2022-02-17 22:51:20

如Mark所述,您可以在

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;
}