使用 panelGrid 时出现 xhtml 错误



我在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>

包含此部分后出现错误:

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

我已经为 p 元素添加了命名空间,但仍然无法将其包含在 panelGrid 中。 有人可以告诉我我做错了什么吗? 错误是:

2017-02-07 14:52:12,275 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 2) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "auctioner-0.0.1-SNAPSHOT.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit."auctioner-0.0.1-SNAPSHOT.war#auctionPersistenceUnit"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit."auctioner-0.0.1-SNAPSHOT.war#auctionPersistenceUnit": javax.persistence.PersistenceException: [PersistenceUnit: auctionPersistenceUnit] Unable to build Hibernate SessionFactory
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: auctionPersistenceUnit] Unable to build Hibernate SessionFactory
Caused by: org.hibernate.MappingException: Could not determine type for: java.util.List, at table: AUCTION, for columns: [org.hibernate.mapping.Column(categories)]"}}

根据您的问题,当您尝试添加 selectOneRadio 时会出现错误,你使用 c 作为 var,然后你把类别作为 itemLabel,这是错误的,var 用于引用你在 f:selectItems 中显示的对象,所以要定义标签,你必须使用 var,像这样:

itemLabel="#{c}"
itemValue="#{c}"

和值应该是你定义的类别列表,并将其填写在托管Bean中:

value="#{newAuctionWizard.categories}"

检查质数:http://www.primefaces.org/showcase/ui/input/oneRadio.xhtml

相关内容

  • 没有找到相关文章

最新更新