【发布时间】:2012-11-18 03:55:25
【问题描述】:
我无法从查询中提取信息并将其放入数据表中。
我需要提取高于输入价格的图书条目。
我认为这部分有点工作,但我需要将它分类到数据表中以便可以读取。 (让它看起来很漂亮)
我不明白我在哪里缺少代码??在查询中整理出来更多?或者我可以只访问信息并将其放入数据表中。
这是我的 BookQueries.xhtml 页面的样子,但它不起作用! :(
<h:dataTable id="table1" value="#{bookController.findBookGreater()}" var="item"
border="1">
<f:facet name="header">
<h:outputText value="Book Query Results" />
</f:facet>
<h:column>
<f:facet name="header">
<h:outputText value="Books" />
</f:facet>
<h:outputText value="#{book.title}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Price" />
</f:facet>
<h:outputText value="#{book.price}" />
</h:column>
</h:dataTable>
在 BookController.java 类中我有:
public List<Book> findBookGreater() {
return ejbFacade.findBookByPrice(bookPrice);
}
在 BookFacade.java 我有:
public List<Book> findBookByPrice(Integer bprice) {
EntityManager em = getEntityManager();
Query query = em.createNamedQuery("findBooksGreater");
query.setParameter("bookprice", bprice);
List resultList = query.getResultList();
return resultList;
}
感谢您提供的任何帮助!!
【问题讨论】:
标签: java jsf jakarta-ee datatable