这不是我第一次使用primefaces的数据表,但这次行号显示正确但单元格为空
这是 page.xhtml :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>All data</title>
</h:head>
<h:body>
<h:form>
<p:dataTable var="client" value="#{candndiateDataComponent.allClient}">
<p:column>
<f:facet name="header">
<h:outputText value="Firstname" />
</f:facet>
<h:outputText value="#{client.firstname}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="LastName" />
</f:facet>
<h:outputText value="#{client.lastname}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="phone" />
</f:facet>
<h:outputText value="#{client.phone}" />
</p:column>
</p:dataTable>
</h:form>
</h:body>
</html>
这是 managedBean CandndiateDataComponent :
@ManagedBean
@SessionScoped
public class CandndiateDataComponent implements Serializable {
@ManagedProperty(value = "#{clientService}")
ClientService clientService;
List<Client> allClient;
Client selectedClient;
@PostConstruct
public void init() {
selectedClient=new Client();
}
public List<Client> getAllClient() {
allClient =(List<Client>) this.clientService.getAllClient();
return allClient;
}
public void setAllClient(List<Client> allClient) {
this.allClient = allClient;
}
public Client getSelectedClient() {
return selectedClient;
}
public void setSelectedClient(Client selectedClient) {
this.selectedClient = selectedClient;
}
public ClientService getClientService() {
return clientService;
}
public void setClientService(ClientService clientService) {
this.clientService = clientService;
}
}