2010-08-10 74 views
4

我想实现一个非常简单的RichFaces的应用程序(以下在developer guide的例子,但我遇到一个错误我解决不了。“没有标签,发现”错误

我的代码似乎建立和正确部署Tomcat的(本地主机),但该指数在打开页面时,我得到异常:

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的风景,我也补充说:
的BeanUtils,集合,沼气池,登录

从RichFaces的,我说: RichFaces的-API,RichFaces的 - implement执行,RichFaces的 - implement执行-JSF2,RichFaces的-UI

如果提供bean代码和/或web.xml是有用的,请说出来,我只是想避免一个可能是一个简单的错误的巨大的帖子。

回答

1

你在使用RichFaces 3.x吗?我最近遇到了同样的问题(虽然在我的情况下我不能使用JSF2.0 h:按钮),我的队友用google搜索了一下,我们只需等待RichFaces 4.0(如果你不解决它真的希望我明天可以问他有没有链接的链接)。

+0

是的,我忘了添加RichFaces的版本... v3.3.3.Final。如果你能找到那个链接,那就太好了,因为我真的很想更多地理解这个问题。 JSF 2.0在1.2上似乎有了这样的改进,并且RichFaces似乎很好地扩展了JSF,所以如果它遇到了我遇到的一些不兼容问题,而不是可以解决的问题,那将是一个巨大的耻辱! – obfuscation 2010-08-10 17:57:04

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> 

,并尝试以下修改的摘录

<?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它被宣布后的身体,但之前关闭</a4j:form>

+0

添加了这些内容(两者均缺失)后,我现在没有收到任何错误,但是页面上的内容在浏览器中完全不呈现。在浏览器中查看源代码时,这表明所有嵌入的标签都没有被解析。你有什么进一步的建议可能是错的? – obfuscation 2010-08-11 08:10:36

+0

尝试用更新答案中的代码片段替换您的代码。它应该有所帮助。 – 2010-08-11 08:59:47

+0

不幸的是,上面没有任何改变......我反而采取了一个示例项目,并从中修改。出于某种原因,我仍然无法理解它是如何影响我的。不过谢谢 – obfuscation 2010-08-12 07:57:03

1

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

4

对于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>