【问题标题】:JSF 2.1.13 custom component not found: Tag Library supports namespace: <namsepace> but no tag was defined for name: <compositecomponent>未找到 JSF 2.1.13 自定义组件:标记库支持命名空间:<namsepace> 但未为名称定义标记:<compositecomponent>
【发布时间】:2014-09-08 23:13:36
【问题描述】:

问题

我正在使用 JSF 2.1.13 创建一个原型,以展示 JSF 相对于我们当前使用 JSP 和 struts 1.1 构建的 web 应用程序的优势。我使用与JSF 2.2.6 一起使用的代码来跟踪代码,但是一旦我发现Oracle Weblogic 12c 还不支持JSF 2.2,我就不得不降级。使用 2.1.13 运行代码时,我收到以下错误:

/pages/sites/tab-details.xhtml @27,90 <ccc:codedType> Tag Library supports namespace: http://java.sun.com/jsf/composite/ccc, but no tag was defined for name: codedType

谷歌搜索仅将我指向 bug about nested composite components,但这不是我正在做的事情。

代码

摘自pom.xml

<!-- JSF Dependencies -->
<dependency>
  <groupId>com.sun.faces</groupId>
  <artifactId>jsf-api</artifactId>
  <version>2.1.13</version>
</dependency>
<dependency>
  <groupId>com.sun.faces</groupId>
  <artifactId>jsf-impl</artifactId>
  <version>2.1.13</version>
</dependency>

复合组件:webapp/WEB-INF/resources/ccc/codedType.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<ui:component xmlns="http://www.w3.org/1999/xhtml"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:cc="http://java.sun.com/jsf/composite">
  <cc:interface shortDescription="Renders a CodedType">
    <cc:attribute name="value" required="true"
      shortDescription="Instance of CodedType to be properly rendered"
      type="company.prototype.uireplacement.presenter.CodedType" />
    <cc:attribute name="includeCode"
      shortDescription="Whether or not the rendeder type should include the code"
      type="boolean" default="false"/>
  </cc:interface>

  <cc:implementation>
    <span id="#{cc.attrs.id}">#{cc.attrs.value.label}<ui:fragment rendered="#{cc.attrs.includeCode}"> (#{cc.attrs.value.code})</ui:fragment></span>
  </cc:implementation>
</ui:component>

使用复合组件的页面:webapp/pages/sites/tab-details.xhtml

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:p="http://primefaces.org/ui"
  xmlns:ccc="http://java.sun.com/jsf/composite/ccc">

      <ccc:codedType value="#{siteControllerBean.selectedSite.type}" includeCode="true"/>
</ui:composition>

【问题讨论】:

    标签: java jsf-2 composite-component mojarra


    【解决方案1】:

    我最近收到此错误: 确保将模板放在位置 src../META-INF/resources/myFolder 并使用 xmlns:tp="http://java.sun.com/jsf/composite/myFolder"> 引用它 这帮助我解决了问题。

    【讨论】:

      【解决方案2】:

      经过更多挖掘,我发现了导致我的错误的原因。注意我的组件的位置:webapp/WEB-INF/resources/ccc/codedType.xhtml。适当的位置应该是webapp/resources/ccc/codedType.xhtml(root vs WEB-INF)。在 JSF 2.2 中,他们允许配置位置,我的 web.xml 中有以下内容:

      <context-param>
        <param-name>javax.faces.WEBAPP_RESOURCES_DIRECTORY</param-name>
        <param-value>/WEB-INF/resources</param-value>
      </context-param>
      

      这就是在 JSF 2.2 中工作的原因。

      针对我的情况的解决方法是删除 javax.faces.WEBAPP_RESOURCES_DIRECTORY,因为它没有在 JSF 2.1 中使用,并将资源移动到根目录。

      【讨论】:

      • 谢谢,帮了我很多忙
      猜你喜欢
      • 2014-09-13
      • 2023-03-25
      • 2016-04-09
      • 2012-07-03
      • 1970-01-01
      • 1970-01-01
      • 2013-04-07
      • 2020-05-16
      相关资源
      最近更新 更多