无法从同一 p:tab 中的另一个表单更新组件

Cannot update component from another form in the same p:tab

问题是在添加 primefaces tabView 之前一切正常,我能够从第一个表单更新第二个表单,现在使用相同的代码引发此异常:

org.primefaces.expression.ComponentNotFoundException

代码如下:

<p:tab title="profils">

    <h:form class="searchForm">
            <h:outputText value="Recherche:" />
            <p:inputText id="globalFilter" value="#{profil.login}" onkeyup="myCommand();" 
      style="width:150px" placeholder="Filtrer par login"/>
            <p:remoteCommand name="myCommand" actionListener="#{profil.getTheProfils()}" 
                     update=":profilForm" style="display: none;" />
        </h:form>
    <br/>



    <h:form id="profilForm">
    <p:growl id="growl" showDetail="true" sticky="false" />  
    <h:panelGroup id="wrapper">
    <p:dataTable value ="#{profil.profils}" var ="p" rows="5"
             paginator="true"
             paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} 
                {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
             rowsPerPageTemplate="3,5,15" resizableColumns="true" style="margin-bottom:20px" 
             id="profilTable">

   <p:column headerText="Login">                    
      <h:inputHidden value = "#{profil.login}" size = "10" rendered = "#{edit.id eq p.login}" 
    class="form-control"/>                  
      <h:outputText value = "#{p.login}" rendered = "#{edit.id ne p.login}" />
   </p:column>
    </p:dataTable>
   </h:panelGroup>
   </h:form>


</p:tab>

我试过 update="profilTable" update=":profilForm:profilTable" update="@profilTable" ...

p:tab 分配在 p:tabView 中,看起来像这样:

<p:tabView id="tabView">
    <p:tab>
        <h:form id="searchForm">
            <p:remoteCommand ... update="tabView:profilForm:profilTable" />
        </h:form>
    </p:tab>

    <p:tab>
        <h:form id="profilForm">
            <p:dataTable id="profilTable">
                ...
            </p:dataTable>
        </h:form>
    </p:tab>
</p:tabView>

这应该可以解决 org.primefaces.expression.ComponentNotFoundException。导致此错误的原因是 tabView 是命名容器 (see this)。通过在搜索表达式前添加 tabView 的 ID 来修复此错误。


相关问题

Naming Container in JSF2/PrimeFaces

How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar"