【问题标题】:Eclipse + JSF + Facelets + composite component = CANNOT_FIND_FACELET_TAGLIBEclipse + JSF + Facelets + 复合组件 = CANNOT_FIND_FACELET_TAGLIB
【发布时间】:2012-04-18 08:52:29
【问题描述】:

我正在尝试将复合组件添加到我的 JSF Facelets 应用程序中。

复合组件(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="my@email.address" />
    </h:form>
</body>
</html>

我的复合组件的路径是src/main/webapp/resources/emcomp/email.xhtml。 我的用户页面的路径是src/main/webapp/emailuserpage.xhtml

但我在 emailuserpage.xhtml 中同时收到编译时和运行时警告,并且浏览器中没有显示任何内容(除了警告消息)

Eclipse JSF HTML 编辑器中显示的编译时警告:

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

Eclipse 浏览器中显示的运行时警告(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/配置问题吗?

[编辑]

回应丹尼尔的评论

SOURCE 目录结构:

  • 项目/src/main/
    • java/
    • 网络应用/

DEPLOY 目录结构:

  • 项目
    • HTML 文件
    • resources/(包括 emcomp/ 文件夹)
    • 元信息/
    • WEB-INF/(配置文件和 lib/ 文件夹)

【问题讨论】:

  • 你确定路径不应该是:webapp/resources/ 而不是 src/main/webapp/resources/ 吗?
  • @Daniel,我使用的是默认的 Maven 目录结构。有关详细信息,请参阅已编辑的问题。
  • 只是古玩用 替换 ,这些东西会弄乱 JSF ...
  • 感谢您的提示,但没有帮助

标签: java eclipse jsf-2 facelets composite-component


【解决方案1】:

从 XML 命名空间 URI 中删除尾部斜杠。

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

【讨论】:

  • 我有同样的问题,但没有斜杠:(
猜你喜欢
  • 1970-01-01
  • 2014-05-16
  • 2011-03-17
  • 2011-06-16
  • 2011-06-27
  • 2013-03-23
  • 2013-04-22
  • 2011-06-04
  • 1970-01-01
相关资源
最近更新 更多