Displaying data with dataTable
thejavafreak Mar 14, 2007 11:05 PMHow do I display data with dataTable ?
From my debug page the query is able to fetch one row of data, but why the rowAvailable is false? How do I set it to true? Is this what cause my data is not able to be displayed?
class class org.jboss.seam.jsf.ListDataModel
dataModelListeners []
rowAvailable false
rowCount 1
rowData java.lang.IllegalArgumentException[null]
rowIndex -1
wrappedData [com.taxandtech.smerp.model.Supplier@1776426]
toString() org.jboss.seam.jsf.ListDataModel@1187f9
class class org.jboss.seam.jsf.ListDataModel
dataModelListeners []
rowAvailable false
rowCount 1
rowData java.lang.IllegalArgumentException[null]
rowIndex -1
wrappedData [com.taxandtech.smerp.model.Supplier@1776426]
toString() org.jboss.seam.jsf.ListDataModel@1187f9
@Stateful
@Scope(ScopeType.SESSION)
@Name("supplierAction")
public class SupplierAction implements SupplierService, Serializable
{
private static final long serialVersionUID = -3563521924777729108L;
@PersistenceContext(type=PersistenceContextType.EXTENDED) EntityManager em;
@In private FacesMessages facesMessages;
@Out @In(create=true) Supplier supplier;
@DataModel List<Supplier> suppliers;
@Logger private static Log log = Logging.getLog(SupplierAction.class);
@Create @Begin(nested=true, pageflow="supplier")
public void begin(){}
@Restrict public void save()
{
log.debug("Supplier name = #0", supplier.getName());
em.persist(supplier);
facesMessages.add("Successfully saved");
}
public String search()
{
log.debug("Supplier name (in) = #0", supplier.getName());
suppliers = (List<Supplier>)searchQuery(supplier.getName()).getResultList();
Iterator iterator = suppliers.iterator();
while(iterator.hasNext())
{
supplier = (Supplier)iterator.next();
log.debug("Supplier name (out) = #0", supplier.getName());
}
return "searchSupplier";
}
public List<Supplier> getSuppliers()
{
return suppliers;
}
public void setSuppliers(List<Supplier> suppliers)
{
this.suppliers = suppliers;
}
public Query searchQuery(String name)
{
return em.createQuery("from Supplier s where s.name like :name").setParameter("name", name);
}
public void reset() {}
@Remove @Destroy
public void destroy() {}
}
<f:subview rendered="#{!suppliers.rowAvailable}">
<h:outputText value="#{messages['nodata']}"/>
</f:subview>
<f:subview rendered="#{suppliers.rowAvailable}">
<h:outputText value="#{suppliers}" />
<h:dataTable id="suppliers" value="#{suppliers}" var="supplier">
<h:outputText value="#{supplier.name}" />
</h:dataTable>
</f:subview>
Have I missed out on something here?
Thanks in advance