将Jsf应用程序集成到Liferay中

问题描述:

我正在开发一个JSF 2.0(带有primefaces 3.2)应用程序,并且我想将我的JSF应用程序集成到Liferay中.我是Liferay的新手,并且要求该应用程序可以通过Liferay进入.

I am developing a JSF 2.0 (with primefaces 3.2) application, and I want to integrate my JSF application inside Liferay. I am new to Liferay and the requirement is that the application will have entrance through Liferay.

这意味着用户将登录,这应该通过Liferay进行.然后,正如我在liferay基本视频中看到的那样,登录liferay后出现了"Liferayhomepage".

That means User will login, which should happen through Liferay. Then as I have seen in liferay basic videos after login in liferay 'Liferayhomepage' comes.

现在,请指导我,在该主页内或登录后,我应该能够看到我正在开发的JSF应用程序,(可以说我的应用程序将是liferay中的portlet),对吗?并且应该能够根据您在Liferay中应用的角色"进行导航.我该怎么办?

Now please guide me, inside that homepage or after login I should be able to see a JSF application that I am developing, (you can say my application will be a portlet inside liferay) right? and should be able to navigate according to 'roles' that you have applied in Liferay. How can I do that?

第二个问题是,一旦我进入JSF应用程序,肯定是 我将需要唯一的'userId'来执行插入和 从数据库中检索数据.我如何在我的JSF中使用它 应用?如果有人可以用一个简单的例子来解释,那将是 真的很有帮助,因为这是我被困住的地方.请帮忙 我出来.

Second question is once I have entered inside my JSF aplication, definitely I will need 'userId' which will be unique, to perform insertion and retrieval of data from database. How can I use it inside my JSF applcation? If anybody can explain with a simple example, it will be really helpful, as this is the point where I am stuck. Please help me out.

简而言之,是否可以通过以下方式调用单独的JSF应用程序: 生命之光?在这里,我通过liferay进入是因为liferay提供了角色",因此一旦通过liferay登录,他就应该能够根据角色(例如admin,power user等)进入我的JSF应用程序.我想做)

In short is it possible to call separate JSF application through liferay? here I am giving entrance through liferay because liferay provides "roles", so that once the logs in through liferay he should be able to enter my JSF application based on the roles (like admin, power user etc..) (This is what exactly I want to do)

请让我知道是否有人需要进一步说明我的问题.

Please let me know if anybody needs more clarification on my question.

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