简体   繁体   中英

jsf: update component (table cell <-> detail panel) => javax.faces.FacesException: Cannot find component with expression

I have a problem about reference in a form. In the same form, I have a - table generated with tags - a panel, allowing user to edit cell content (with multiple inputs and informations)

I use a <p:commandButton> with a <f:setPropertyActionListener> to store the cell value and refresh the detail's panel. This part as no problem.

When the user's edit ends, he save its changes by clicking on "save" button in the detail panel. I'd like to refresh only the previously selected cell and not the whole table. So I had a to save the Component.clientId and put a "renderer=xxx" on the button to be sure the id is not null.

But it always throws javax.faces.FacesException...

  <table class="measureTable" id="measureTable">
     <!-- header -->
     <tbody ... >
        <tr class="ui-column-title">
           <th ...> ...</th>
           <ui:repeat var="columnHeader" value="#{managedBean.columnModels}" id="columnHeaders" >
              <th ><p:outputLabel value="#{columnHeader.name}" /></th>
           </ui:repeat>
        </tr>

        <!-- datas --> 
        <ui:repeat var="vLine" value="#{managedBean.roundvLines}" id="lines" >
           <tr>
              <td >
                 <p:panel styleClass="cellPanel">
                    <p:outputLabel value="#{vLine.id}" styleClass="ui-column-header" />
                 </p:panel>
              </td>

              <ui:repeat var="vCell" value="#{vLine.cells}" id="cells">
                 <td>
                    <p:commandButton  styleClass="cellPanel" value="#{vCell.value}" update=":formControl:detailPanel" >
                       <f:setPropertyActionListener value="#{vCell}" target="#{managedBean.currentCell}" />
                       <f:setPropertyActionListener value="#{component.clientId}" target="#{managedBean.currentComponentId}" />
                    </p:commandButton>
                 </td>
              </ui:repeat>
           </tr>
        </ui:repeat>
     </tbody>
  </table>


  <p:panel id="detailPanel">
     <p:panel rendered="#{!empty managedBean.currentCell}" styleClass="panelWithoutBorder">
        <ui:param name="definition" value="#{managedBean.currentCell.measureDefinition}"/>
        <ui:param name="measure" value="#{managedBean.currentCell}"/>

        <p:panel id="detailValue" header="Valeur">
           <!--  NUM    -->
           <p:keyboard value="#{measure.value}" keypadOnly="true"
              rendered="#{definition.codeTypeSais == 1}" />

           <!--  STR    -->
           <p:keyboard value="#{measure.value}"
              rendered="#{definition.codeTypeSais == 2}"/>
           ...
        </p:panel>
        ...
        <p:panel>
           <p:commandButton value="refresh" update=":formControl:specimen:0"
           rendered="#{!empty managedBean.currentComponentId}"></p:commandButton>
        </p:panel>
     </p:panel>
  </p:panel>

GRAVE: javax.faces.FacesException: Cannot find component with expression ":formControl:lines:0:cells:0:j_idt20" referenced from "j_idt36". at org.primefaces.expression.SearchExpressionFacade.resolveComponentInternal(SearchExpressionFacade.java:422) at org.primefaces.expression.SearchExpressionFacade.resolveComponentForClient(SearchExpressionFacade.java:200) at org.primefaces.expression.SearchExpressionFacade.resolveComponentsForClient(SearchExpressionFacade.java:147) at org.primefaces.util.AjaxRequestBuilder.addExpressions(AjaxRequestBuilder.java:92) at org.primefaces.util.AjaxRequestBuilder.update(AjaxRequestBuilder.java:85) at org.primefaces.renderkit.CoreRenderer.buildAjaxRequest(CoreRenderer.java:356) at org.primefaces.component.commandbutton.CommandButtonRenderer.buildRequest(CommandButtonRenderer.java:123) ...

I allready read following topics:

use-an-el-expression-to-pass-a-component-id-to-a-composite-component-in-jsf

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

I can't use binding because components are auto generated and too many.

The component already existe because the page haven't changed. I tried too update only the top/left cell, using its id gaven by the stacktrace but an Exception is still throwed. It only works when I update the whole form (update=":formControl")... :S

how can I solve it?

PS: I used primefaces but the final terminal is an old company android 2.3.4 with default browser and lots of stuff doesn't work so i have to do it manually.

I fixed this 2 weeks ago in PrimeFaces with some other improvements on the SearchExpressionFramework. Please try a trunk build - if it doesn't work, create a an issue please + full example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM