1

I'm using JSF 2.2 and primefaces 6.0

And I have a table in this form

        <table>
            <tr>
                <td rowspan="2">
                    Direction
                </td>
                    <td colspan="#{etpBean.activites.size()}">
                    Activites
                </td>
                </td>
                    <td rowspan="2">
                    Controle
                </td>
            </tr>

            <tr>
              <ui:repeat var="activite" value="#{etpBean.activites}">
                        <td>
                            <h:outputText value="#{activite.nom}"/>
                        </td>
              </ui:repeat>
            </tr>

            <ui:repeat value="#{etpBean.affectations}" var="affectation">
               <tr> 
                <ui:repeat var="activite" value="#{etpBean.activites}">

                <td rowspan="#{etpBean.affectations.size()}"><h:outputText  value="#{affectation.structure.nom}" />
                </td>

                <td>
                    <p:inputText value="#{etpBean.getValeurActivite(affectation,activite).etp}" required="true">
                    <p:ajax listener="#{etpBean.onControleChange(affectation)}" update="controle" event="blur" />
                    </p:inputText>                                                  
                </td>
                <td>    
                <h:outputText id="controle" value="#{etpBean.message}"/>
                </td>
                </ui:repeat>
               </tr> 
            </ui.repeat>
      </table>

For each row of this table i have many inputs of the same type, in my listener onControleChange i retrieve the values of these inputs As i calculate the sum after each entry and i want to update the column controle if the sum more than 100 i want to put not ok else Ok.

Here is the onControleChange

public void onControleChange(Affectation affectation){
    double somme=0;

    for (ETP  etp : etpss) {

        if(etp.getAffectation().equals(affectation) && etp.getEtp() != null){
            somme+=etp.getEtp();
        }
    affectation.setSomme(somme);
    }
    if(somme>100){
        this.message="Not ok";
    }else{
        this.message="Ok";
    }
}

but when i run my XHTML this error appears

Grave: org.primefaces.expression.ComponentNotFoundException: Cannot find component for expression "controle" referenced from "form:j_idt77:0:j_idt94:0:j_idt96".

I don't know if it's because of ui: repeat all of the column " contrôle " takes the same id.

Any idea ??

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Rodik
  • 271
  • 2
  • 19
  • Hi, Start with assigning id's to all namingcontainers and components. Easier to 'debug' for yourself to and 'good practice' in general, remove all code that does not change the behaviour you see and make it a [mcve] and read all of the >50 upvoted questions and answers in Stackoverflow so you know most basic/relevant things (e.g. http://stackoverflow.com/questions/8634156/how-to-find-out-client-id-of-component-for-ajax-update-render-cannot-find-compo) – Kukeltje Apr 28 '17 at 13:34
  • This latter link contains a reference to http://stackoverflow.com/questions/7415230/uiform-with-prependid-false-breaks-fajax-render which might cause your problem but we cannot see since you did not post an [mcve]... – Kukeltje Apr 28 '17 at 13:39
  • it's my first time in stack i will read the minimal Complete.. and i will update my question thank u @Kukeltje – Rodik Apr 28 '17 at 13:41
  • Great... For the 'id' thing in my first comment, you could use http://showcase.omnifaces.org/viewhandlers/NoAutoGeneratedIdViewHandler to help you implement this 'strategy' during development – Kukeltje Apr 28 '17 at 13:42

1 Answers1

1

Did you try

<p:ajax listener="#{etpBean.onControleChange(affectation)}" process="@this" update=":#{p:component('controle')}" event="blur" />
CHARAFI Saad
  • 1,340
  • 3
  • 16
  • 36