加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 找不到JSF 2.1.13自定义组件:标签库支持命名空间:但没

发布时间:2020-12-14 05:53:55 所属栏目:Java 来源:网络整理
导读:问题 我正在使用JSF 2.1.13创建一个原型来展示JSF对我们当前使用JSP和struts 1.1构建的webapp的好处.我使用JSF 2.2.6的代码跟踪代码,但是一旦我发现Oracle Weblogic 12c还不支持JSF 2.2,我就不得不降级.使用2.1.13运行代码时收到以下错误: /pages/sites/tab
问题

我正在使用JSF 2.1.13创建一个原型来展示JSF对我们当前使用JSP和struts 1.1构建的webapp的好处.我使用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>

Composite Compontent: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>

解决方法

经过多次挖掘后,我发现了导致我错误的原因.请注意我的组件的位置: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中使用并将资源移动到根.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读