0

I have a .xhtml file contains 1 form and 1 dialog, as example:

<h:form id="frmMain">
   <p:dataTable id="tblFormItem"
                widgetVar="wgFormItem">
      <p:column>
      ...
      </p:column>
   </p:dataTable>
   <p:commandButton value="Add value"
                    onstart="PF('dlg').show()"
                    oncomplete="PF('dlg').hide()"
                    action="#{bean.openDialog}"/>   <!-- openDialog() will open a dialog has id "dialog" -->
</h:form>

<p:dialog id="dialog"
          widgetVar="wgDialog">
   <h:form id="dialogForm">
      <!-- Some stuffs -->
      <p:commandButton value="Save"
                       update=":messages :frmMain:tblFormItem"
                       action=#{bean.save}"/>

I got the error Cannot find component for expression ":frmMain:tblFormItem".

I searched and tried everything that I found on Google but it still produces the same error.

Please help me, how do I update the dataTable from commandButton in dialog?

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
  • See https://stackoverflow.com/questions/8634156/how-to-find-out-client-id-of-component-for-ajax-update-render-cannot-find-compo – Jasper de Vries Sep 24 '21 at 07:04
  • Thanks for your answer, I did have a look at it, and turned out I didn't research deep enough. I just look at those answers without clicking on the links. I think that using `@widgetVar` solved my problem. – Minh Nguyên Nguyễn Đức Sep 24 '21 at 07:16

0 Answers0