0
<h:form id="form">
        <p:messages />
        <p:panel header="Análise">
            <h:outputText value="Mês da análise: " />

            <p:selectOneMenu value="#{report005.selectedMes}">
                <f:selectItems var="data" value="#{report005.analiseMeses}" itemLabel="#{report005.formataDataCombo(data)}" />
                <f:convertDateTime pattern="MM/yyyy" />
            </p:selectOneMenu>

            <p:commandButton value="Análises" update="analiseTable" actionListener="#{report005.loadAnalise()}" />

            <p:dataTable id="analiseTable" var="pes" value="#{report005.analiseModel}" selection="#{report005.selectedAnalise}" emptyMessage="Não há registros...">

                <p:column selectionMode="multiple" style="width:18px" />

                <p:ajax event="rowSelectCheckbox" listener="#{report005.loadAnaliseProduto()}" update="produtosmanycheck" />

                <p:column headerText="Código">  
                    #{pes.cod_analise}  
                </p:column>

                <p:column headerText="Nome">  
                    #{pes.dsc_analise}  
                </p:column>

                <p:column headerText="Descrição">  
                    #{pes.dsc_resumida_acao}  
                </p:column>

                <p:column headerText="Planejamento">
                    <h:outputText value="#{pes.dat_planejamento_analise}">
                        <f:convertDateTime pattern="dd/MM/yyyy" />
                    </h:outputText>
                </p:column>

            </p:dataTable>
        </p:panel>
        <p:panel header="Produto Gerencial">

            <p:selectManyCheckbox id="produtosmanycheck" value="#{report005.selectedProduto}" layout="pageDirection">
                <f:selectItems id="teste" value="#{report005.produtos}" />
            </p:selectManyCheckbox>

        </p:panel>
        <p:commandButton value="Enviar" action="#{report005.send}" ajax="false" />
    </h:form>

Whan the AJAX event "rowSelectCheckbox" is fired, it does not find the 'produtosmanycheck' component to update, returning the following error to me:

javax.faces.FacesException: Cannot find component with identifier "produtosmanycheck" referenced from "form:analiseTable". at org.primefaces.util.ComponentUtils.findClientIds(ComponentUtils.java:251) at org.primefaces.util.AjaxRequestBuilder.addIds(AjaxRequestBuilder.java:102) at org.primefaces.util.AjaxRequestBuilder.update(AjaxRequestBuilder.java:90)

I already tried= :form:produtosmanycheck, form:produtosmanycheck, :produtosmanycheck, produtosmanycheck

I tried removing the FORM id too... without success...

What am I doing wrong? I can't update any component but the DataTable...

BBacon
  • 2,456
  • 5
  • 32
  • 52
  • Related: http://stackoverflow.com/questions/8634156/how-to-reference-components-in-jsf-ajax-cannot-find-component-with-identifier/8644762#8644762 – BalusC Oct 02 '12 at 11:24
  • @BalusC I opened the html of the generated page, and this is the code generated for my selectManyCheckbox:
    – BBacon Oct 02 '12 at 11:57
  • Don't you have _nested_ `forms`, do you ? – Fallup Oct 02 '12 at 12:48
  • Yes, 1 nested. prependId set to False. – BBacon Oct 02 '12 at 13:06
  • when you look at the component in browser's page source what id do you see? – velo Oct 02 '12 at 13:14
  • You should never nest forms in JSF, that may be the problem – Jordan Denison Oct 02 '12 at 13:17
  • @Joshi its described 4 messages up this one.
    ... the aswer is then: form:produtosmanycheck.
    – BBacon Oct 02 '12 at 13:40
  • @JordanDenison I removed the "father" form and it worked. I don't see why that's a problem, the prependId property was set to false and it refused to find the component either way. Please post your answer so I can mark it as correct. – BBacon Oct 02 '12 at 14:04
  • You are welcome. Love it when I find the issue and someone else post it, or not even post it but edit the old **bad** answer:) – Fallup Oct 02 '12 at 14:26

3 Answers3

5

You can reach that produtosmanycheck using :form:produtosmanycheck

EDIT: Nested forms will not work properly and give all kinds of DOM issues like the one you're experiencing. Work out a way to separate your view components into separate forms and then try the above named access.

kolossus
  • 20,559
  • 3
  • 52
  • 104
  • This should definitely work. If it is not working for you @MBarni , then you've checked it wrong or you have another problem. Try it once more, and see if javax.faces.FacesException appears or if it is just not updated. – Fallup Oct 02 '12 at 07:52
  • Nope. The problem persists: > javax.faces.FacesException: Cannot find component with identifier > ":form:produtosmanycheck" referenced from "form:analiseTable". at > org.primefaces.util.ComponentUtils.findClientIds(ComponentUtils.java:251) > at > org.primefaces.util.AjaxRequestBuilder.addIds(AjaxRequestBuilder.java:102) > at > org.primefaces.util.AjaxRequestBuilder.update(AjaxRequestBuilder.java:90) – BBacon Oct 02 '12 at 11:36
  • @MBarni set `prependId=false` on the form – kolossus Oct 02 '12 at 14:31
  • It's not about `id`s, nested forms are forbidden. – Fallup Oct 02 '12 at 14:38
  • @Fallup. I completely missed that in the question. Nested forms? Heck no! – kolossus Oct 02 '12 at 14:40
  • Because it wasn't in the question, read the comments under the question. – Fallup Oct 02 '12 at 14:41
3

Have you tried putting the id "produtosmanycheck" on the parent p:panel element instead of on the p:selectManyCheckbox itself?

Form nesting should never be done in JSF even with prepend ID false as it will cause unexpected or no behaviour.

Jordan Denison
  • 2,649
  • 14
  • 14
  • 1
    Form nesting should be never done ever, not only in JSF. Also the first part of your answer has nothing to do with the actual problem. – Fallup Oct 02 '12 at 14:32
3

I will post my own answer (in the end I came up with nested forms idea) as well as voting up @kolossus because he was basically right and couldn't know about nested forms.

Nested forms aren't the "thing" of JSF only (as it may seem from @JordanDenison answer), it is a general rule of HTML --> nesting forms is forbidden in HTML !

You may want to read this nesting forms in HTML

Community
  • 1
  • 1
Fallup
  • 2,417
  • 19
  • 30