0

I am using socialauth to login via facebook in my jsf application. It works fine. If i click a jsf commandlink's action method i am connecting to facebook. like below

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

In index.xhtml page

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

this is working fine, But the OAuth page opening in the same window. i need to open the facebook page in new window? is there any configuration available...? any help would be appreciated.

EDIT: if i use

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

the above code facebook loginpage opening in new tab but after logged in i need to close the window and redired to my page. any help would be appreciated.

Ramakrishna
  • 426
  • 7
  • 26

1 Answers1

0

<p:commandLink/> is representative of a vanilla HTML hyperlink, which means it also has the target attribute. Set that to _blank as you would a regular HTML hyperlink

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

</p:commandLink>
kolossus
  • 20,559
  • 3
  • 52
  • 104
  • insted of p:commandLink use h:commandLink its working but i need to close the new window after logged in to facebook and return to page. – Ramakrishna Oct 11 '14 at 08:46
  • That's a different question @Ramakrishna – kolossus Oct 11 '14 at 09:09
  • Your current problem is not a good question as it's likely to get closed as "Too broad". The current problem is not a programming question, it's a design question and doesn't fit within [the guidelines of a good question](http://stackoverflow.com/help/dont-ask). Besides that, you're not supposed to just edit an existing question to ask a different question, now that you've gotten an answer to your previous problem (The title of your question, for example, doesn't fit what you're now asking does it?). Ask a brand new question (which would probably get closed anyway) – kolossus Oct 11 '14 at 09:46