如何将 Facebook 插件与 JSF 2 页面集成?
我想将 facebook“喜欢”按钮集成到我的页面,所以结果如下:
<!DOCTYPE html>
<html lang="pt-br"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:fb="http://ogp.me/ns/fb#">
<h:head>
</h:head>
<h:body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '<filled with my app id>', // App ID
channelURL : '//www.suaparte.org', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
oauth : true, // enable OAuth 2.0
xfbml : true // parse XFBML
});
// Additional initialization code here
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
<div id="header">
<ui:insert name="header">
Header area. Please insert the header!
</ui:insert>
</div>
<div id="content">
<ui:insert name="content">
Content area. Please insert the content!
</ui:insert>
</div>
<div id="footer">
<fb:like href="suaparte.org" send="true" width="450" show_faces="true"></fb:like>
</div>
</h:body>
</html>
出现“喜欢”按钮,但下面出现以下消息:
Warning: This page calls for XML namespace http://ogp.me/ns/fb# declared with prefix fb but no taglibrary exists for that namespace.
I would like to integrate a facebook 'like' button to my page, so here is the result:
<!DOCTYPE html>
<html lang="pt-br"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:fb="http://ogp.me/ns/fb#">
<h:head>
</h:head>
<h:body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '<filled with my app id>', // App ID
channelURL : '//www.suaparte.org', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
oauth : true, // enable OAuth 2.0
xfbml : true // parse XFBML
});
// Additional initialization code here
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
<div id="header">
<ui:insert name="header">
Header area. Please insert the header!
</ui:insert>
</div>
<div id="content">
<ui:insert name="content">
Content area. Please insert the content!
</ui:insert>
</div>
<div id="footer">
<fb:like href="suaparte.org" send="true" width="450" show_faces="true"></fb:like>
</div>
</h:body>
</html>
The button 'like' appears but below appears the follow message:
Warning: This page calls for XML namespace http://ogp.me/ns/fb# declared with prefix fb but no taglibrary exists for that namespace.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
忽略警告。它来自 Facelets,这是一种基于 XML 的视图技术,并期望所有 XML 命名空间都引用 Facelets 标记库。在开发过程中,当您尝试引用类路径中根本不存在的 Facelets 标记库时,此警告应该会有所帮助。例如,当您尝试使用 RichFaces 组件但忘记实际安装 RichFaces 时。
对于 Facebook,XML 命名空间实际上由客户端的 JavaScript 进行解释,并且工作正常,因此您可以安全地忽略该警告。如果您将
javax.faces.PROJECT_STAGE
设置为Production
,它无论如何都不会出现。仅当设置为开发
时,这些警告才会出现。Ignore the warning. It's coming from Facelets which is a XML based view technology and expects all the XML namespaces to refer to Facelets tag libraries. This warning is supposed to be helpful during development for the case that you're trying to refer a Facelets tag library which doesn't exist in the classpath at all. For example, when you're trying to use RichFaces components but forgot to actually install RichFaces.
In case of Facebook the XML namespace is actually to be interpreted by the JavaScript in the client side and it is working fine, so you can safely ignore the warning. It won't appear anyway if you have
javax.faces.PROJECT_STAGE
set toProduction
. Those warnings appear only when it's set toDevelopment
.