警告:此页面调用以前缀fb声明的XML名称空间http://www.facebook.com/2008/fbml,但该名称空间不存在taglibrary

Wan*_*fee 4 jsf facelets facebook-javascript-sdk

我正在使用Javascript为网站开发FB登录应用程序.我尝试在HTML中工作正常.当我转换为JSF时,它会出错.

这是我的fbLogin.xhtml代码.

<?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">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:fb="http://www.facebook.com/2008/fbml">
    <h:head>
        <title>FB Login</title>
        <link rel="stylesheet" type="text/css" href="./xmlhttp/css/rime/rime.css"/>
    </h:head>
    <h:body styleClass="ice-skin-rime">   

   <fb:login-button scope="email"></fb:login-button> 
    <script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : '<APP_ID>',
      status     : true, // check login status
      cookie     : true, // enable cookies to allow the server to access the session
      xfbml      : true  // parse XFBML
    });

    // Additional initialization code here

    showMe = function(response) {
      if (response.status !== 'connected') {
        div.innerHTML = '<em>Not Connected</em>';
      } else {
        FB.api('/me', function(response) {
          var i=0;
          for (var key in response) {

            i++;

            switch(i){
            case 1: document.getElementById("formId:id").value=response[key]; break;
            case 2: document.getElementById("formId:name").value=response[key]; break;
            case 5: document.getElementById("formId:link").value=response[key]; break;
            case 6: document.getElementById("formId:userName").value=response[key]; break;
            case 19: document.getElementById("formId:email").value=response[key]; break;
           }  

          }

        });
      }
    };
  FB.getLoginStatus(function(response) {
    showMe(response);
    FB.Event.subscribe('auth.authResponseChange', showMe);
  });
  };

  // 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));
</script>  

       <h:form id="formId">
        <table>
        <tr><td><a>ID : <h:inputText id="id" value="#{fbLogin.id}" /> </a></td></tr>
        <tr><td><a>Name : <h:inputText id="name" value="#{fbLogin.name}" /> </a></td></tr>
        <tr><td><a>Link : <h:inputText id="link" value="#{fbLogin.link}" /> </a></td></tr>
        <tr><td><a>User Name : <h:inputText id="userName" value="#{fbLogin.userName}" /> </a></td></tr>
        <tr><td><a>E-Mail : <h:inputText id="email" value="#{fbLogin.email}" /> </a></td></tr>
        <tr><td><h:commandButton value="Register" action="#{fbLogin.Display}" /></td></tr>                                      
        </table>    
      </h:form>         
    </h:body>
</html>
Run Code Online (Sandbox Code Playgroud)

使用JSF编写代码的原因是,我需要将用户信息输入到我的backBean中以存储到数据库中.

当我尝试运行这个应用程序时,我在浏览器中收到警告:

Warning: This page calls for XML namespace http://www.facebook.com/2008/fbml declared with prefix fb but no taglibrary exists for that namespace.

我的代码中有什么错误?

Bal*_*usC 5

当您将您将得到这个javax.faces.PROJECT_STAGEDevelopment在Web应用程序的web.xml和Facelets遇到它无法解析到一个JSF兼容的标签库中的XML命名空间.此警告仅显示为通知(开始)开发人员XML命名空间中可能无法预料的拼写错误或标记库配置中的错误.

但是,在这个特殊情况下,有问题的XML命名空间实际上是指外部Facebook JavaScript API,而不是诸如PrimeFaces,OmniFaces等JSF标记库.您的代码完全正常.

你可以忽略这个警告.将JSF项目阶段设置回时Production,或者删除整个上下文参数(默认为Production已经存在)时,不会出现此警告.