我在我的应用程序中使用素面数据表,当我选择任何给定表时
它返回我以下错误
有人帮忙吗?我用了primefaces 3.5
JSF 2.1
我的primefaces数据表
lazyDataModel = new LazyDataModel<Funcionario>()
{
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public List<Funcionario> load(int first, int pageSize,
String sortField, SortOrder sortOrder,
Map<String, String> filters) {
try {
funcionarios = funcionarioService.listar(first, pageSize, filters);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(getRowCount() <= 0)
{
setRowCount(funcionarioService.getRowCount());
}
setPageSize(pageSize);
super.setWrappedData(funcionarios);
return funcionarios;
}
@Override
public Object getRowKey(Funcionario item) {
System.out.println(item.getCodigo());
return item.getCodigo();
}
@Override
public Funcionario getRowData(String rowKey) {
// TODO Auto-generated method stub
Integer id = Integer.valueOf(rowKey);
for (Funcionario funcionario : (List<Funcionario>) getWrappedData()) {
if(id.equals(funcionario.getCodigo()))
{
return funcionario;
}
}
return null;
}
@Override
public void setRowIndex(int rowIndex) {
/*
* The following is in ancestor (LazyDataModel):
* this.rowIndex = rowIndex == -1 ? rowIndex : (rowIndex % pageSize);
*/
if (rowIndex == -1 || getPageSize() == 0) {
super.setRowIndex(-1);
}
else
super.setRowIndex(rowIndex % getPageSize());
}
};
}
我的 listagem.xhtml
?xml version="1.0" encoding="ISO-8859-1" ?>
<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
</h:head>
<h:form id = "f">
<p:dataTable emptyMessage="Não tem registros." var = "funcionario"
value = "#{bean.getLazyDataModel()}" paginator="true" rows = "5" id = "tbf"
rowsPerPageTemplate="5,10,15" lazy = "true" filterEvent="enter"
selection="#{bean.selecionado}" selectionMode="single" rowKey="#{bean.funcionario.codigo}"
>
<p:ajax event="rowSelect" update=":t:dialogf:display" oncomplete="funcionarioDialog.show()"/>
<p:column filterBy="#{funcionario.codigo}" headerText="Codigo" filterMatchMode="contains"
>
<h:outputText value="#{funcionario.codigo}" />
</p:column>
<p:column filterBy="#{funcionario.nome}" headerText="Nome" filterMatchMode="contains">
<h:outputText value="#{funcionario.nome}" />
</p:column>
<p:column filterBy="#{funcionario.cpf}" headerText="Cpf" filterMatchMode="contains">
<h:outputText value="#{funcionario.cpf}" />
</p:column>
<p:column filterBy="#{funcionario.dataNascimento}" headerText="Data Nascimento" filterMatchMode="contains" >
<h:outputText value="#{funcionario.dataNascimento}" >
<f:convertDateTime type="date" pattern="dd/MM/yyyy" />
</h:outputText>
</p:column>
<p:column filterBy="#{funcionario.usuario}" headerText="Usuario" filterMatchMode="contains">
<h:outputText value="#{funcionario.usuario}" />
</p:column>
<p:column headerText = "Excluir">
<p:commandLink action ="#{funcionarioBean.excluir()}" update = "tbf" >
excluir
<f:setPropertyActionListener target="#{funcionarioBean.funcionario}" value="#{funcionario}" />
</p:commandLink>
</p:column>
<p:column style="width:4%">
<p:commandButton id="selectButton" update = ":t:dialogf:display" value = "ver"
oncomplete="funcionarioDialog.show()" title="View">
<f:setPropertyActionListener target="#{bean.selecionado}" value="#{funcionario}" />
</p:commandButton>
</p:column>
<p:column headerText = "Alterar">
<p:commandButton id="selectButton2" update = ":t:" value = "Alterar" title="Alterar">
<f:setPropertyActionListener target="#{bean.funcionario}" value="#{funcionario}" />
</p:commandButton>
</p:column>
</p:dataTable>
</h:form>
<h:form id = "dialogf">
<p:dialog id = "dialog" header = "Detalhes do Registro" widgetVar="funcionarioDialog" resizable = "false"
showEffect="fade" hideEffect="explode">
<h:panelGrid id = "display" columns="2" cellpadding="4">
<h:outputText value="Codigo:" />
<h:outputText value="#{bean.selecionado.codigo}" />
<h:outputText value="Nome:" />
<h:outputText value="#{bean.funcionario.nome}" />
<h:outputText value="Cpf:" />
<h:outputText value="#{bean.funcionario.cpf}" />
<h:outputText value="Data Nascimento:" />
<h:outputText value="#{bean.funcionario.dataNascimento}" >
<f:convertDateTime type="date" pattern="dd/MM/yyyy" />
</h:outputText>
<h:outputText value="Usuario:" />
<h:outputText value="#{bean.funcionario.usuario}" />
<h:outputText value="Senha:" />
<h:outputText value="#{bean.funcionario.senha}" />
</h:panelGrid>
</p:dialog>
</h:form>
</html>
错误
Set 04, 2013 9:40:56 AM com.sun.faces.context.PartialViewContextImpl processPartial
INFO: java.lang.NullPointerException
java.lang.NullPointerException
at org.primefaces.component.datatable.DataTable.getRowData(DataTable.java:936)
at org.primefaces.component.datatable.feature.SelectionFeature.decodeSingleSelection(SelectionFeature.java:47)
at org.primefaces.component.datatable.feature.SelectionFeature.decode(SelectionFeature.java:38)
at org.primefaces.component.datatable.DataTableRenderer.decode(DataTableRenderer.java:57)
at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:787)
at org.primefaces.component.api.UIData.processDecodes(UIData.java:228)
at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:506)
at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
at org.primefaces.component.api.UIData.visitTree(UIData.java:639)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
at javax.faces.component.UIForm.visitTree(UIForm.java:344)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
at org.primefaces.component.tabview.TabView.visitTree(TabView.java:419)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:376)
at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:252)
at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:183)
at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:931)
at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:409)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:178)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)