Forms 使用panelGrid时出现xhtml错误

Forms 使用panelGrid时出现xhtml错误,forms,jsf,primefaces,xhtml,panelgrid,Forms,Jsf,Primefaces,Xhtml,Panelgrid,我在xhtml中遇到一个错误。。 代码是: <h:form> <h:panelGrid columns="2"> <h:outputLabel value="Name:" /> <h:inputText value="#{newAuctionWizard.auction.name}" /> <h:outputLabel value="Description:" /> <h:inputTexta

我在xhtml中遇到一个错误。。 代码是:

<h:form>
  <h:panelGrid columns="2">
    <h:outputLabel value="Name:" />
    <h:inputText value="#{newAuctionWizard.auction.name}" />

    <h:outputLabel value="Description:" />
    <h:inputTextarea value="#{newAuctionWizard.auction.description}" />

    <p:outputLabel for="category" value="Categories from which to pick:" />
    <p:selectOneRadio id="category" value="#{newAuctionWizard.auction.category}"  
     layout="grid" columns="3">
      <f:selectItems value="#{newAuctionWizard.auction.categories}" 
       var="c" itemLabel="#{category}" itemValue="#{category}"/>
    </p:selectOneRadio>

    <h:commandButton value="Cancel" action="#{newAuctionWizard.cancel()}" />    
    <h:commandButton value="Details" action="newAuctionDetails" />  
  </h:panelGrid>

根据您的问题,当您尝试添加selectOneRadio时会出现错误, 您使用c作为var,然后将category作为itemLabel,这是错误的,var用于引用您在f:selectItems中显示的对象,因此要定义标签,您必须使用var,如下所示:

itemLabel="#{c}"
itemValue="#{c}"
值应该是您定义的类别列表,并将其填入managedBean:

value="#{newAuctionWizard.categories}"

检查primefaces:

您的标题说明您遇到了“错误”(标题太笼统),但您甚至没有在文本中发布错误。这样就不可能有帮助了(这里有可疑的向上投票)错误是什么?我现在已经编辑了..抱歉:)您正在引用一个类别列表的值,而该列表在拍卖中不存在,请参见我的答案。它们在拍卖中。。私有列表+getter和setters完成。。它现在显示:新的缺少/未满足的依赖项:service jboss.deployment.unit。“auctioner-0.0.1-SNAPSHOT.war”。WeldbootstrapsService(缺少)依赖项:[service jboss.deployment.unit。“auctioner-0.0.1-SNAPSHOT.war”。component.AuctionManagerImpl.WeldInterceptorBindingsService,service jboss.deployment.unit。“auctioner-0.0.1-SNAPSHOT.war”.component.NewAuctionWizard.WeldInstantiator,服务jboss.deployment.unit。“auctioner-0.0.1-SNAPSHOT.war”。component.UserManagerImpl.WeldInstantiator,服务此日志与选择器无关。您必须将itemLabel=“#{c}”itemValue=“#{c}”,并确保auction.category是Stringdone..现在它显示:2017-02-07 15:48:01479 INFO[org.jboss.as.repository](ServerService线程池--60)WFLYDR0011:无法列出C:\Users\user\Downloads\wildfly-10.0.0.Final(1)的目录文件\wildfly-10.0.0.Final\standalone\data\content…真的不知道发生了什么耶,对不起..上面写着:SNAPSHOT.war#auctionPersistenceUnit\“:javax.persistence.PersistenceException:[PersistenceUnit:auctionPersistenceUnit]无法构建Hibernate会话工厂,原因是:javax.persistence.PersistenceException:[PersistenceUnit:auctionPersistenceUnit]无法生成Hibernate SessionFactory,原因是:org.Hibernate.MappingException:无法确定以下列的类型:[org.Hibernate.mapping.Column(categories)]“}
itemLabel="#{c}"
itemValue="#{c}"
value="#{newAuctionWizard.categories}"