错误
AVERTISSEMENT: /pages/centres.xhtml @151,196 value="#
{centreMB.currentCentre.matricule}": Target Unreachable, 'currentCentre' returned null
javax.el.PropertyNotFoundException: /pages/centres.xhtml @151,196 value="#
{centreMB.currentCentre.matricule}": Target Unreachable, 'currentCentre' returned null
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100)
at org.primefaces.renderkit.InputRenderer.findImplicitConverter(InputRenderer.java:170)
at org.primefaces.renderkit.InputRenderer.findConverter(InputRenderer.java:190)
at org.primefaces.renderkit.InputRenderer.getConvertedValue(InputRenderer.java:196)
CentreManagedBean.java
public void onSelectCentreForUpdate(Centre centre) {
try {
setCurrentCentre(centre);
setIdcentreselected(centre.getIdcentre());
} catch (Exception e) {
System.out.println(e);
}
}
/**
* Modifier Médecin
*
* @return vide
*/
public void updateCentre() {
try {
Centre c=getCentreService().getCentreById(getIdcentreselected());
c.setMatricule(currentCentre.getMatricule());
c.setAdresse(currentCentre.getAdresse());
c.setUpdatedAt(new Date());
getCentreService().updateCentre(c);
} catch (DataAccessException e) {
System.out.println(e);
}
}
centre.xhtml
<p:column style="width:0.5%">
<p:commandButton icon="ui-icon-pencil" actionListener="#{centreMB.onSelectCentreForUpdate(centre)}" update=":editCentre:updatePanel" oncomplete="updateCentre.show()"/>
</p:column>
<!-- Modification -->
<p:dialog header="Modification du centre" widgetVar="updateCentre" resizable="false" id="editP" modal="true">
<p:messages id="msgs"/>
<h:panelGrid columns="2" id="updatePanel">
<h:outputLabel for="matricule" value="Matricule: *" />
<p:inputText id="matricule" value="#{centreMB.currentCentre.matricule}" required="true" label="Matricule" style="width: 205px" requiredMessage="Matricule: Champ obligatoire"/>
<h:outputLabel for="nom" value="Nom: *" />
<p:inputText id="nom" value="#{centreMB.currentCentre.nom}" required="true" label="Firstname" style="width: 205px" requiredMessage="Nom: Champ obligatoire"/>
<h:outputLabel for="prenom" value="Adresse: " />
<p:inputTextarea id="prenom" value="#{centreMB.currentCentre.adresse}" label="Surname" required="false" style="width: 205px" />
</h:panelGrid>
<p:separator/>
<p:commandButton styleClass="ui-panel-titlebar-icon ui-corner-all ui-state-default" id="enregsitrer" value="Enregistrer" update="msgs" actionListener="#{centreMB.updateCentre}" ajax="true" style="width: 248px;" oncomplete="handleDialogSubmitUpdate(xhr, status, args)"/>
<p:commandButton type="button" styleClass="ui-panel-titlebar-icon ui-corner-all ui-state-default" value="Annuler" ajax="true" onclick="updateCentre.hide()"/>
</p:dialog>
</h:form>
感谢您的帮助问候
答案 0 :(得分:0)
我认为你得到的错误就是空了。 组织如下:
private CurrentCentre currentCentre= new CurrentCentre();
或
public CurrentCentre getCurrentCentre(){
if(currentCentre == null)
currentCentre = new CurrentCentre();
return currentCentre;
}