[jboss-user] [JBoss Seam] - Retreiving data based on displayed data

felixk2 do-not-reply at jboss.com
Thu Jan 3 16:52:43 EST 2008


I'm not sure if I am doing this correctly so any help would be appreciated. Here is the situation: I have a page that displays a particular Customer. Underneath that Customer i'd like to list all the orders.

I've created a bean with the following method:

public List<CustomerProduct> customerProductListByCustomer(Customer customer)

I  have a rich:datatable on the view that calls this method and fills in the table. Problem is I need to use this method to determine if the table should be rendered. So I  have the following in the view:

<h:outputText value="No Customer Products Exist." rendered="#{empty customerProductList.customerProductListByCustomer(customerHome.instance)}"/>
  |     <rich:dataTable id="customerProductList" var="customerProduct"
  |          	value="#{customerProductList.customerProductListByCustomer(customerHome.instance)}"
  |          	rendered="#{not empty customerProductList.customerProductListByCustomer(customerHome.instance)}">
  |     	<rich:column>
  |      		<f:facet name="header">Name</f:facet>
  |            	#{customerProduct.productInstanceName}
  |         </rich:column>
  | 	</rich:dataTable>

The problem with this approach is that now Hibernate queries my database 3 times. Twice to check if there is data to render, and once to populate the table.

My question is, is my method the standard way to do this? I'd rather just have a bean with an @Out that I can use to check if is empty and use to populate the datatable, but then I can't pass it an argument (in this case the customer). Any suggestions?


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4116876#4116876

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4116876

More information about the jboss-user mailing list