just wanted to share a working example of Facebook Login integration in an ADF application, that only uses default ADF Faces tags. Here is how the JSF can look like:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<af:document title="untitled1.jsf" id="d1">
<af:form id="f1">
<af:pageTemplate viewId="/oracle/templates/threeColumnTemplate.jspx" id="pt1">
<f:facet name="center">
<af:panelBox text="PanelBox2" id="pb2">
<f:facet name="toolbar"/>
<af:panelGroupLayout id="pgl1" layout="vertical">
<af:outputText value="Facebook Login" id="ot2"/>
<af:outputText value="<fb:login-button show-faces="true" width="200" max-rows="1"></fb:login-button>" id="ot1"
escape="false"/>
</af:panelGroupLayout>
</af:panelBox>
</f:facet>
<f:facet name="header">
<af:outputText value="<div id="fb-root"></div>" id="ot3" escape="false"/>
</f:facet>
<f:facet name="end">
<af:panelBox text="PanelBox3" id="pb3">
<f:facet name="toolbar"/>
</af:panelBox>
</f:facet>
<f:facet name="start">
<af:panelBox text="PanelBox1" id="pb1">
<f:facet name="toolbar"/>
</af:panelBox>
</f:facet>
<f:facet name="branding"/>
<f:facet name="copyright"/>
<f:facet name="status"/>
</af:pageTemplate>
</af:form>
<f:facet name="metaContainer">
<af:resource type="javascript">
window.fbAsyncInit = function() {
FB.init({
appId : '115771338443915', // App ID
channelUrl : 'http://localhost:8081/Application7-ViewController-context-root/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.Event.subscribe('auth.authResponseChange', function(response) {
// Here we specify what we do with the response anytime this event occurs.
if (response.status === 'connected') {
// The response object is returned with a status field that lets the app know the current
// login status of the person. In this case, we're handling the situation where they
// have logged in to the app.
testAPI();
} else if (response.status === 'not_authorized') {
// In this case, the person is logged into Facebook, but not into the app, so we call
// FB.login() to prompt them to do so.
// In real-life usage, you wouldn't want to immediately prompt someone to login
// like this, for two reasons:
// (1) JavaScript created popup windows are blocked by most browsers unless they
// result from direct interaction from people using the app (such as a mouse click)
// (2) it is a bad experience to be continually prompted to login upon page load.
FB.login();
} else {
// In this case, the person is not logged into Facebook, so we call the login()
// function to prompt them to do so. Note that at this stage there is no indication
// of whether they are logged into the app. If they aren't then they'll see the Login
// dialog right after they log in to Facebook.
// The same caveats as above apply to the FB.login() call here.
FB.login();
}
});
};
// Load the SDK asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
// Here we run a very simple test of the Graph API after login is successful.
// This testAPI() function is only called in those cases.
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
console.log('Response: ' + response);
});
}
</af:resource>
</f:facet>
</af:document>
</f:view>
Note that you must have created a Facebook App on Facebook.com which provides the AppId number and set the App in "Sandbox" mode.
The jsf works in JDeveloper 11.1.2.4 and Glassfish 3.1.2 and ADF Essentials 11.1.2.4