[英]javax.el.ELException: java.lang.NullPointerException
I use primefaces single row selection data table , and i want to change a value on the selected row so this is my xhtml page 我使用primefaces单行选择数据表,并且我想更改所选行的值,所以这是我的xhtml页面
<h:form id="form">
<p:panel header="Prix des matériaux " style="width : 664px; " >
<br />
<p:dataTable id="cars" var="car" value="#{materielbean.listitemsmaterielBean}"
rowKey="#{car.iditemsmateriel}" paginator="true" rows="20"
selection="#{materielbean.selecteditemforprix}" selectionMode="single" >
<p:ajax event="rowSelect" update=":form:dialog" oncomplete="PF('carDialog').show()"/>
<f:facet name="header">
Liste de de matériel
</f:facet>
<p:column headerText="Désignation" filterBy="designation" >
#{car.designation}
</p:column>
<p:column headerText="Unité">
#{car.unite}
</p:column>
<p:column headerText="Prix en DT" >
#{car.prix}
</p:column>
</p:dataTable>
<p:dialog id="dialog" header="Changer le prix d'un article" widgetVar="carDialog"
resizable="true" showEffect="fade" hideEffect="explode">
<h:panelGrid columns="3">
<h:outputText value=" #{materielbean.selecteditemforprix.designation}" />
<p:inputText value="#{materielbean.selecteditemforprix.prix}"/>
<p:commandButton value="OK" action="#{materielbean.modifprixofitem()}"
onclick="PF('carDialog').hide()" update=":form:cars" />
</h:panelGrid>
</p:dialog>
</p:panel>
</h:form>
And this is the backing bean to modify the selected object 这是修改所选对象的支持Bean
@ManagedBean(name="materielBean")
@SessionScoped
private ItemsMateriel selecteditemforprix;
public ItemsMateriel getSelecteditemforprix() {
return selecteditemforprix;
}
public void setSelecteditemforprix(ItemsMateriel selecteditemforprix) {
this.selecteditemforprix = selecteditemforprix;
}
public void modifprixofitem() {
itemmaterielDAO.Modifitemsmateriel(selecteditemforprix );
selecteditemforprix = new ItemsMateriel();
}
When I click "OK" I take the new value from the inputtext, update my object in the database and finally I update the data table, but when I did it like that, I got an error which says 当我单击“确定”时,我从输入文本中获取新值,更新数据库中的对象,最后更新数据表,但是当我这样做时,出现错误提示
22:16:48,999 GRAVE [javax.enterprise.resource.webcontainer.jsf.context] (http-localhost-127.0.0.1-8383-6) javax.el.ELException: /Gestionstock/Materiel/Matos.xhtml @28,97 rowKey="#{car.iditemsmateriel}": java.lang.NullPointerException
Well the problem is in the last lign selecteditemforprix = new ItemsMateriel();
好了,问题出在最后一次selecteditemforprix = new ItemsMateriel();
。itemforprix selecteditemforprix = new ItemsMateriel();
i don't really know what's the problem with that lign but when i deleted it everything works fine, any other clarifications will be appreciated . 我真的不知道该逻辑的问题是什么,但是当我删除它时,一切正常,其他的说明将不胜感激。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.