Edit
I will ask the question differently,
This is my code
<p:remoteCommand name="setTab_#{ss.level}" action="#{planMediaControllerInternet.affecterLigneCalcul(ss)}"/>
<p:selectOneMenu id="supportForRegieInternet" value="#{ss.supportInternet}" converter="supportInternetConverter" onkeydown="setTab_#{ss.level}" onchange="setTab_#{ss.level}" >
<f:selectItem itemLabel="-----" />
<f:selectItems value="#{planMediaControllerInternet.lstSupportForFournisseurItem()}" />
<p:ajax event="valueChange" listener="#{planMediaControllerInternet.affecterLigneCalcul(ss)}" update="typePW,nbVisU,classAx,prestationForSupportInternet,supportForRegieInternet"/>
</p:selectOneMenu>
I want that in this code, the method affecterLigneCalcul is called before the method getAsObject of the converter, is this possible ?
this is my converter
@FacesConverter(value="supportInternetConverter")
@RequestScoped
public class SupportInternetConverter implements Converter{
@Inject
RegieController regieController;
@Inject
SessionController sessionController;
@Inject
PlanMediaControllerInternet planMediaControllerInternet;
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
PlanMediaInternetLigneCalcul pmilc = planMediaControllerInternet.getPlanMediaInternetLigneCalculSelected();
RegieInternet regieInternet = pmilc.getRegieInternet();
if (regieInternet != null) {
for(SupportInternet r : regieInternet.getLstSupportInternet()) {
if(r.getNameSupport().equals(value)){
return r;
}
}
}
return null;
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
if(value != null){
SupportInternet r = (SupportInternet)value;
return r.getNameSupport();
}
return "";
}
Edit the problem is not because of NullPointerException
Edit
this is my affecterLigneCalcul function
public void affecterLigneCalcul (PlanMediaInternetLigneCalcul tmpPlanMediaInternetLigneCalcul) {
planMediaInternetLigneCalculSelected = tmpPlanMediaInternetLigneCalcul;
}