0

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;
}
ktaria
  • 423
  • 6
  • 16
  • 1
    You forgot to tell about the concrete problem. Is it that you're getting a `NullPointerException` because `planMediaControllerInternet` is actually not been injected and thus still `null`? Please edit and improve the question accordingly. – BalusC Mar 22 '13 at 20:42
  • I have added almost all the jsf file, I hope this is clearer (I know this don't fillfull the condition you put of "**just copy'n'paste'n'running**") – ktaria Mar 22 '13 at 21:37
  • I have changed the manner of question, I went directly to the heart of problem – ktaria Mar 23 '13 at 11:14
  • It will also help if your code is in *English* (this bring an English site afteral). Because you used some (for me) unreadable foreign language for your methods etc, my brain just resists reading your code. I've got a feeling many people will have the same reaction, and as a result you'll not get much answers. – Mike Braun Mar 23 '13 at 14:26
  • As per your edited question, that's not how JSF works. Why exactly do you want to invoke the listener before the model is applied/validated/converted/updated? What's the concrete functional requirement for which you thought that this is the solution? – BalusC Mar 23 '13 at 18:06
  • In the converter, there is a reference to the current row. I want to invoke the listener before the converter because I want to tell to the converter which row to treat. The problem is when the user navigate from one selectOneMenu in one row to another in other row. – ktaria Mar 23 '13 at 19:46
  • Thanks I found the solution in [How do I pass a parameter value to a Conversion class in java?][1] [1]: http://stackoverflow.com/questions/6930994/how-do-i-pass-a-parameter-value-to-a-conversion-class-in-java – ktaria Apr 18 '13 at 15:48

0 Answers0