【问题标题】:JSF2: Tag Library supports namespace: http://java.sun.com/jsf/composite/components/customer, but no tag was defined for name: listJSF2:标签库支持命名空间:http://java.sun.com/jsf/composite/components/customer,但没有为名称定义标签:list
【发布时间】:2012-09-09 01:40:33
【问题描述】:

我为客户列表创建了一个复合组件。我可以在视图中使用这个组件:

<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:ui="http://java.sun.com/jsf/facelets"
  xmlns:p="http://primefaces.org/ui"
  xmlns:customer="http://java.sun.com/jsf/composite/components/customer">

<ui:composition template="/WEB-INF/templates/template.xhtml">

  <ui:define name="caption">
    <h:outputText value="#{msg.customerListHeading}" />
  </ui:define>

  <ui:define name="content">

    <ui:decorate template="/WEB-INF/templates/sidebox.xhtml">
      <ui:param name="title" value="#{msg.customerListHeading}" />

      <p:outputPanel>
        <h:form id="customerList">

          <customer:list list="#{customerControllerBean.list}">
            <f:facet name="headerButton">
              <h:button outcome="customerdetail.jsf"
                value="#{msg.newButtonLabel}" />
            </f:facet>
            <f:facet name="rowButton">
              <h:commandButton value="#{msg.deleteButtonLabel}"
                action="#{customerControllerBean.delete(customer)}" />
              <h:button outcome="customerdetail.jsf?id=#{customer.id}"
                value="#{msg.editButtonLabel}" />
            </f:facet>
          </customer:list>

        </h:form>
      </p:outputPanel>
    </ui:decorate>

  </ui:define>

</ui:composition>

</html>

但是当我在一个非常相似的视图中使用该组件时,我收到以下错误:

<customer:list> Tag Library supports namespace: http://java.sun.com/jsf/composite/components/customer, but no tag was defined for name: list

有问题的视图如下所示:

<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:ui="http://java.sun.com/jsf/facelets"
  xmlns:p="http://primefaces.org/ui"
  xmlns:customer="http://java.sun.com/jsf/composite/components/customer">

<ui:composition template="/WEB-INF/templates/template.xhtml">

  <ui:define name="caption">
    <h:outputText value="#{msg.customerListHeading}" />
  </ui:define>

  <ui:define name="content">

    <ui:decorate template="/WEB-INF/templates/sidebox.xhtml">
      <ui:param name="title" value="#{msg.customerListHeading}" />

      <p:outputPanel>
        <h:form id="customerList">

          <customer:list list="#{customerControllerBean.list}">
            <f:facet name="rowButton">
              <h:commandButton value="#{msg.applyButtonLabel}"
                action="#{orderControllerBean.setCustomer(customer)}" />
            </f:facet>
          </customer:list>

        </h:form>
      </p:outputPanel>
    </ui:decorate>

  </ui:define>

</ui:composition>

</html>

正如您所见,这两个视图的不同之处仅在于我用于向客户列表表添加按钮的方面,因为我在两种不同的上下文中使用该列表。但是为什么第二个视图不起作用呢?

我发现 Mojarra 存在/曾经存在问题,但我使用所谓的稳定版本来解决这个问题:

2012-09-16 19:09:41,512 INFO     [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-4) Mojarra 2.1.7-jbossorg-1 (20120227-1401)

【问题讨论】:

    标签: jsf-2 mojarra


    【解决方案1】:

    eclipse查看的文件夹路径(组件)不正确

    从构建路径中移除 src/main/resource -- 构建路径==> 从构建路径中移除。
    并在构建路径中再次添加

    【讨论】:

      【解决方案2】:

      我在 Mojarra Jira 上找到了解决此问题的方法: http://java.net/jira/browse/JAVASERVERFACES-2437

      我将xmlns:customer="http://java.sun.com/jsf/composite/components/customer" 放在ui:composition 标记中,视图渲染成功:

      <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:ui="http://java.sun.com/jsf/facelets"
        xmlns:p="http://primefaces.org/ui"
        xmlns:customer="http://java.sun.com/jsf/composite/components/customer">
      
      <ui:composition template="/WEB-INF/templates/template.xhtml" xmlns:customer="http://java.sun.com/jsf/composite/components/customer">
      
        <ui:define name="caption">
          <h:outputText value="#{msg.customerListHeading}" />
        </ui:define>
      
        <ui:define name="content">
      

      ...

      根据那个 Jira,问题在 Mojarra 2.1.10 中得到了修复,所以我希望 JBoss 尽快更新 AS 7.1... :)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-07-09
        • 2016-04-09
        • 1970-01-01
        • 1970-01-01
        • 2012-07-03
        • 1970-01-01
        • 2012-09-18
        相关资源
        最近更新 更多