【问题标题】:"no tag was found" Error“未找到标签”错误
【发布时间】:2011-03-27 23:31:55
【问题描述】:

我正在尝试实现一个非常简单的 RichFaces 应用程序(按照developer guide 的示例,但遇到了一个我无法解决的错误。

我的代码似乎可以正确构建并部署到 Tomcat (localhost),但是当打开索引页面时出现异常:

javax.faces.view.facelets.TagException: /index.xhtml @13,19 <a4j:form> Tag Library supports namespace: http://richfaces.org/a4j, but no tag was defined for name: form

我尝试加载的索引页面如下:

<?xml version='1.0' encoding='UTF-8' ?>
<!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:a4j="http://richfaces.org/a4j"
  xmlns:rich="http://richfaces.org/rich"
  xmlns:f="http://java.sun.com/jsf/core">
<h:head>
    <title>Facelet Title</title>
</h:head>
<h:body><f:view>
    <a4j:form>
        <rich:panel header="This is the title" style="width:400px;">
            <h:outputText value="Enter your name:"/>
            <h:inputText value="#{MyBean.message}">
                <f:validateLength minimum="1" maximum="20"/>
            </h:inputText>
        </rich:panel>
    </f:view></a4j:form>
</h:body>
</html>

据我所知,这与开发人员指南中的示例相同。我正在 Netbeans 6.8 中开发,使用 JSF 2.0 的 MyFaces 实现,并添加了 RichFaces 和 Apache Commons jar 作为库,异常声明的标签实际上是 Netbeans 自动建议的!

从 Apache Commons,我添加了:
beanutils,集合,消化器,日志记录

在 RichFaces 中,我添加了: richfaces-api、richfaces-impl、richfaces-impl-jsf2、richfaces-ui

如果提供 bean 代码和/或 web.xml 有用,请这样说,我只是想避免因为可能是一个简单的错误而发布大量帖子。

【问题讨论】:

    标签: richfaces jsf-2


    【解决方案1】:

    对于 RichFaces 4.x,请使用“rich:popupPanel”。我是从 RichShowCase 那里得到的:

    <a4j:status onstart="#{rich:component('statPane')}.show()"
        onstop="#{rich:component('statPane')}.hide()" />
    <h:form id="form">
        <rich:dataTable value="#{carsBean.allInventoryItems}" var="car"
            iterationStatusVar="it" id="table" rows="15">
            <rich:column>
                <f:facet name="header">#</f:facet>
                #{it.index}
            </rich:column>
            <rich:column>
                <f:facet name="header">Vendor</f:facet>
                <h:outputText value="#{car.vendor}" />
            </rich:column>
            <rich:column>
                <f:facet name="header">Model</f:facet>
                <h:outputText value="#{car.model}" />
            </rich:column>
            <rich:column>
                <f:facet name="header">Price</f:facet>
                <h:outputText value="#{car.price}" />
            </rich:column>
            <rich:column>
                <f:facet name="header">Mileage</f:facet>
                <h:outputText value="#{car.mileage}" />
            </rich:column>
            <rich:column>
                <f:facet name="header">VIN</f:facet>
                <h:outputText value="#{car.vin}" />
            </rich:column>
            <rich:column>
                <a4j:commandLink styleClass="no-decor" execute="@this"
                    render="@none" oncomplete="#{rich:component('confirmPane')}.show()">
                    <h:graphicImage value="/images/icons/delete.gif" alt="delete" />
                    <a4j:param value="#{it.index}"
                        assignTo="#{carsBean.currentCarIndex}" />
                </a4j:commandLink>
                <a4j:commandLink styleClass="no-decor" render="editGrid"
                    execute="@this" oncomplete="#{rich:component('editPane')}.show()">
                    <h:graphicImage value="/images/icons/edit.gif" alt="edit"/>
                    <a4j:param value="#{it.index}"
                        assignTo="#{carsBean.currentCarIndex}" />
                    <f:setPropertyActionListener target="#{carsBean.editedCar}"
                        value="#{car}" />
                </a4j:commandLink>
            </rich:column>
            <f:facet name="footer">
                <rich:dataScroller page="#{carsBean.page}" />
            </f:facet>
        </rich:dataTable>
    
        <a4j:jsFunction name="remove" action="#{carsBean.remove}"
            render="table" execute="@this"
            oncomplete="#{rich:component('confirmPane')}.hide();" />
    
    <rich:popupPanel id="statPane" autosized="true">
        <h:graphicImage value="/images/ai.gif" alt="ai" />
        Please wait...
    </rich:popupPanel>
    
    <rich:popupPanel id="confirmPane" autosized="true">
        Are you sure you want to delete the row?
        <a4j:commandButton value="Cancel"
            onclick="#{rich:component('confirmPane')}.hide(); return false;" />
        <a4j:commandButton value="Delete" onclick="remove(); return false;" />
    </rich:popupPanel>
    
    <rich:popupPanel header="Edit Car Details" id="editPane" domElementAttachment="parent" width="400" height="170">
            <h:panelGrid columns="3" id="editGrid">
                <h:outputText value="Vendor" />
                <h:outputText value="#{carsBean.editedCar.vendor}" />
                <h:panelGroup />
                <h:outputText value="Model" />
                <h:outputText value="#{carsBean.editedCar.model}" />
                <h:panelGroup />
                <h:outputText value="Price" />
                <h:inputText value="#{carsBean.editedCar.price}" required="true"
                    requiredMessage="Price is required" id="price"
                    converterMessage="Should be a valid price"
                    validatorMessage="Should be a valid price" label="Price field">
                    <f:validateDoubleRange/>
                </h:inputText>
                <rich:message id="priceMsg" for="price" />
                <h:outputText value="Mileage" />
                <h:inputText value="#{carsBean.editedCar.mileage}" id="mage"
                    converterMessage="Should be a valid mileage"
                    validatorMessage="Should be a valid mileage" label="Mileage field" >
                    <f:validateDoubleRange/>
                </h:inputText>
                <rich:message id="madeMsg" for="mage" />
                <h:outputText value="VIN" />
                <h:inputText value="#{carsBean.editedCar.vin}" id="vin"
                    required="true" validatorMessage="Not a valid 17-digit VIN"
                    converterMessage="Not a valid 17-digit VIN"
                    requiredMessage="VIN is required">
                    <f:validateLength minimum="17" maximum="17" />
                </h:inputText>
                <rich:message id="vinMsg" for="vin" />
            </h:panelGrid>
            <a4j:commandButton value="Store" action="#{carsBean.store}"
                render="table" execute="editPane"
                oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('editPane')}.hide();}" />
            <a4j:commandButton value="Cancel"
                onclick="#{rich:component('editPane')}.hide(); return false;" />
    </rich:popupPanel>
    </h:form>
    

    【讨论】:

      【解决方案2】:

      我正在使用 Richfaces 3.3.3.Final 和 Myfaces 2.0.1 没有任何问题。

      确保您已添加 facelets-1.1.15.B1 以及 web.xml 中的以下上下文参数

      <context-param>
          <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
          <param-value>com.sun.facelets.FaceletViewHandler</param-value>
      </context-param>
      <context-param>
          <param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name>
          <param-value>true</param-value>
      </context-param>
      

      并尝试以下修改后的 sn-p

      <?xml version='1.0' encoding='UTF-8' ?>
      <!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:a4j="http://richfaces.org/a4j"
          xmlns:rich="http://richfaces.org/rich"
          xmlns:f="http://java.sun.com/jsf/core">
      <head>
          <title>Facelet Title</title>
      </head>
      <body>
          <a4j:form>
              <rich:panel header="This is the title" style="width:400px;">
                  <h:outputText value="Enter your name:"/>
                  <h:inputText value="#{MyBean.message}">
                      <f:validateLength minimum="1" maximum="20"/>
                  </h:inputText>
              </rich:panel>
          </a4j:form>
      </body>
      </html>
      

      f:view 存在问题,它在 body 之后声明但在 &lt;/a4j:form&gt; 之前关闭

      【讨论】:

      • 添加了这些(两者都缺失)后,我现在没有收到任何错误,但页面上的内容根本没有在浏览器中呈现。在浏览器中查看源代码,这表明从 嵌套的所有标签都没有被解析。您对可能出现的问题有任何进一步的建议吗?
      • 尝试用更新后的答案中的 sn-p 替换您的代码。它应该会有所帮助。
      • 不幸的是,上述内容没有任何变化......我转而采用了一个示例项目,并从中进行了修改。出于某种原因,我仍然无法看到它有什么使它对我起作用。不过谢谢
      【解决方案3】:

      您使用的是 RichFaces 3.x 吗?我最近遇到了同样的问题(尽管在我的情况下我不能使用 JSF2.0 h:button),我的队友在谷歌上搜索到它与技术有关,我们只需要等待 RichFaces 4.0(如果你不会解决真的很想我明天可以向他要一个链接,如果他还有的话)。

      【讨论】:

      • 是的,我忘了添加 RichFaces 的版本... v3.3.3.Final。如果您能找到该链接,那就太好了,因为我真的很想更多地了解这个问题。 JSF 2.0 似乎比 1.2 有了很大的改进,RichFaces 似乎很好地扩展了 JSF,所以如果它只是我遇到的一些不兼容而不是可以解决的问题,那将是一个巨大的耻辱!
      【解决方案4】:

      我看到您已经添加了richfaces-impl 和richfaces-impl-jsf2 jar。根据建议,如果您使用的是 jsf 2.0,您应该只添加后者。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-11-21
        • 1970-01-01
        • 2013-04-19
        • 2011-05-21
        • 1970-01-01
        • 2016-11-15
        • 2018-02-28
        • 1970-01-01
        相关资源
        最近更新 更多