0

编辑

我会以不同的方式问这个问题,

这是我的代码

<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>

我希望在这段代码中,在转换器的方法 getAsObject 之前调用方法 effecterLigneCalcul,这可能吗?

这是我的转换器

@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 "";
}

编辑 问题不是因为 NullPointerException

编辑

这是我的 effecterLigneCalcul 函数

public void affecterLigneCalcul (PlanMediaInternetLigneCalcul tmpPlanMediaInternetLigneCalcul) {
planMediaInternetLigneCalculSelected = tmpPlanMediaInternetLigneCalcul;
}
4

0 回答 0