2012-04-18 97 views
4

我正在嘗試向我的JSF Facelets應用程序中添加一個複合組件。Eclipse + JSF + Facelets +複合組件= CANNOT_FIND_FACELET_TAGLIB

的複合元件(email.xhtml)如下:

<!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:composite="http://java.sun.com/jsf/composite" 
    xmlns:h="http://java.sun.com/jsf/html"> 

<h:head> 
    <title>This content will not be displayed</title> 
</h:head> 
<h:body> 
    <composite:interface> 
     <composite:attribute name="value" required="false" /> 
    </composite:interface> 

    <composite:implementation> 
     <h:outputLabel value="Email id: "></h:outputLabel> 
     <h:inputText value="#{cc.attrs.value}"></h:inputText> 
    </composite:implementation> 
</h:body> 
</html> 

的使用頁(emailuserpage.xhtml)如下:

<!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:h="http://java.sun.com/jsf/html" 
    xmlns:em="http://java.sun.com/jsf/composite/emcomp/"> 

<h:head> 
    <title>Using a sample composite component</title> 
</h:head> 

<body> 
    <h:form> 
     <em:email value="[email protected]" /> 
    </h:form> 
</body> 
</html> 

到我的複合材料部件的路徑爲src/main/webapp/resources/emcomp/email.xhtml 。 我的用戶頁面的路徑是src/main/webapp/emailuserpage.xhtml

但我得到的編譯時和在emailuserpage.xhtml運行時警告,並沒有什麼(除了警告消息)被顯示在瀏覽器在Eclipse JSF HTML編輯器中顯示

編譯時警告:

在Eclipse瀏覽器中顯示
xmlns:em="http://java.sun.com/jsf/composite/emcomp/" 
NLS missing message: CANNOT_FIND_FACELET_TAGLIB in: 
org.eclipse.jst.jsf.core.validation.internal.facelet.messages 

運行時間警告(javax.faces.PROJECT_STAGE =發展在web.xml):

Warning: The page /emailuserpage.xhtml declares namespace http://java.sun.com/jsf/composite/emcomp/ and uses the tag em:email , but no TagLibrary associated to namespace. 

我已經看到了這個問題(它沒有解決的問題):NLS missing message: CANNOT_FIND_FACELET_TAGLIB

我使用的m2em2e-wtp插件,以Eclipse版本:

Eclipse Java EE IDE for Web Developers 
Version: Indigo Service Release 2 
Build id: 20120216-1857 

任何想法我做錯了什麼? 我是否以某種方式錯誤地包含了複合組件,或者是否使用了錯誤的目錄來存儲我的資源? 這是一個Eclipse /配置問題?

[編輯]

針對丹尼爾的評論

源目錄結構:

  • 項目/ src目錄/主/
    • 的Java/
    • 的webapp/

deploy目錄結構:

  • 項目
    • HTML文件
    • 資源/(包括emcomp /文件夾)
    • META-INF/
    • WEB- INF /(配置文件和lib /文件夾)
+0

你確定路徑不應該是:webapp/resources /而不是src/main/webapp/resources /? – Daniel 2012-04-18 09:18:29

+0

@Daniel,我使用默認的Maven目錄結構。有關更多詳細信息,請參閱編輯的問題 – 2012-04-18 11:42:12

+0

只是古怪替換與,這東西可以攪拌JSF ... – Daniel 2012-04-18 12:03:19

回答

4

從XML命名空間URI中刪除尾部斜槓。

xmlns:em="http://java.sun.com/jsf/composite/emcomp" 
+0

完美,謝謝 – 2012-04-18 13:26:29

+2

我有同樣的問題,但沒有結尾斜槓:( – 2012-09-26 09:44:58