2014-10-10 58 views
0

我正在使用socialauth在我的jsf应用程序中通过Facebook登录。它工作正常。如果我点击一个jsf commandlink的操作方法,我将连接到Facebook。像下面如何使用socialauth作为弹出窗口打开Facebook oauth页面

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 loginpage开在新的选项卡,但登录我需要关闭窗口并redired到我的网页后。任何帮助,将不胜感激。

回答

0

<p:commandLink/>代表了一个香草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> 
+0

其没有工作,不过Facebook页面在同一标签 – Ramakrishna 2014-10-11 08:04:27

+0

开放insted的P的:commandLink使用H:commandLink它的工作,但我需要后关闭新窗口登录到Facebook并返回页面。 – Ramakrishna 2014-10-11 08:46:42

+0

这是一个不同的问题@Ramakrishna – kolossus 2014-10-11 09:09:30

相关问题