【问题标题】:xhtml error when working with panelGrid使用 panelGrid 时出现 xhtml 错误
【发布时间】:2017-06-24 17:39:28
【问题描述】:

我在 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)]"}}

【问题讨论】:

  • 您的标题表明您收到“错误”(标题太笼统),但您甚至没有在文本中发布 WHAT 错误。这样一来,就不可能提供帮助(并且在这里可疑的支持)
  • 错误是什么??
  • 我现在已经完成了编辑......对不起:)
  • 您在价值中引用了一个类别列表,而这在拍卖中不存在,请参阅我的答案。
  • 他们正在拍卖中......私有列表 + getter 和 setter

标签: forms jsf primefaces xhtml panelgrid


【解决方案1】:

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

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

和value应该是你定义的类别列表,并填写在managedBean中:

value="#{newAuctionWizard.categories}"

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

【讨论】:

  • done.. 它现在说:新的缺失/不满足的依赖项:service jboss.deployment.unit."auctioner-0.0.1-SNAPSHOT.war".WeldBootstrapService(缺少)依赖项:[service jboss. deployment.unit."auctioner-0.0.1-SNAPSHOT.war".component.AuctionManagerImpl.WeldInterceptorBindingsService,服务 jboss.deployment.unit."auctioner-0.0.1-SNAPSHOT.war".component.NewAuctionWizard.WeldInstantiator,服务 jboss。 deployment.unit."auctioner-0.0.1-SNAPSHOT.war".component.UserManagerImpl.WeldInstantiator, 服务
  • 此日志与selectOneRadio无关
  • 你必须输入 itemLabel="#{c}" itemValue="#{c}",并确保auction.category 是一个字符串
  • 完成.. 现在它说:2017-02-07 15:48:01,479 INFO [org.jboss.as.repository] ​​(ServerService Thread Pool -- 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] 无法建立休眠会话工厂原因:javax.persistence.PersistenceException:[ PersistenceUnit:auctionPersistenceUnit] 无法构建 Hibernate SessionFactory 原因:org.hibernate.MappingException:无法确定类型:java.util.List,表:AUCTION,列:[org.hibernate.mapping.Column(categories)] "}}
猜你喜欢
  • 2013-05-06
  • 2012-04-25
  • 1970-01-01
  • 2010-11-03
  • 2012-07-31
  • 1970-01-01
  • 2019-11-12
  • 2021-06-18
  • 2014-05-30
相关资源
最近更新 更多