如何使用socialauth打开facebook oauth页面作为弹出窗口

时间:2014-10-10 12:57:34

标签: jsf socialauth

我正在使用socialauth在我的jsf应用程序中通过facebook登录。它工作正常。如果我点击jsf commandlink的动作方法,我将连接到Facebook。如下所示

public void socialConnect(){
    SocialAuthConfig config = SocialAuthConfig.getDefault();
                config.load(new FileInputStream(new File("auth.properties")));
    SocialAuthManager manager = new SocialAuthManager();
                manager.setSocialAuthConfig(config);
    String authenticationURL = manager.getAuthenticationUrl(providerID,
                        "http://mudomain.com/page");
    FacesContext.getCurrentInstance().getExternalContext()
                        .redirect(authenticationURL);
}

在index.xhtml页面

<p:commandLink id="facebook" ajax="false" value="Login with facebook"
                                action="#{userSession.socialConnect}">
                                <f:setPropertyActionListener target="#userSession.providerID}"
                                    value="facebook" />
                            </p:commandLink>

这工作正常,但OAuth页面在同一个窗口中打开。我需要在新窗口中打开Facebook页面?有没有可用的配置......?任何帮助,将不胜感激。

编辑: 如果我使用

<h:commandLink target="_blank" id="facebook" ajax="false" value="Login with facebook"
                                    action="#{userSession.socialConnect}">
                                    <f:setPropertyActionListener target="#userSession.providerID}"
                                        value="facebook" />
                                </h:commandLink>

上面的代码facebook登录页面在新标签中打开但登录后我需要关闭窗口并重新启动到我的页面。任何帮助,将不胜感激。

1 个答案:

答案 0 :(得分:0)

<p:commandLink/>代表一个vanilla HTML超链接,这意味着它还具有target属性。将其设置为_blank,就像常规HTML超链接一样

<p:commandLink target="_blank" id="facebook" ajax="false" value="Login with facebook" action="#{userSession.socialConnect}">
       <f:setPropertyActionListener target="#userSession.providerID}"  value="facebook" />

</p:commandLink>