Primefaces: Modal dialog does not open

1

I'm trying to open Dialog from primefaces, but to no avail. I have the following code:

Registered Clients.xhtml:

...
<ui:define name="content">
    <h:form id="frm-clientes-cadastrados">
        <p:button value="Novo Cliente" styleClass="btn-cadastrar" onclick="cadastroClienteDialog.show(); return false;" />
            <p:dataTable var="cliente" value=...>
                ...
            </p:dataTable>
    </h:form>
</ui:define>

<h:form id="frm-cadastro-cliente-dialog">
    <p:dialog header="Cadastrar Cliente" widgetVar="cadastroClienteDialog" modal="true">
        Conteúdo
    </p:dialog>
</h:form>

In the browser console gives the following error:

  

Uncaught ReferenceError: DatabaseDialog is not defined at HTMLButtonElement.onclick (RegisteredCounts.xhtml: 31)

    
asked by anonymous 25.02.2017 / 21:33

1 answer

1

OnClick can not see your widget in another form.

Include your dialog within your 'frm-registered-clients' form or refer to the form in your onCLick call.

Example:

<ui:define name="content">
<h:form id="frm-clientes-cadastrados">
    <p:button value="Novo Cliente" styleClass="btn-cadastrar" onclick="cadastroClienteDialog.show(); return false;" />
        <p:dataTable var="cliente" value=...>
            ...
        </p:dataTable>
    <p:dialog header="Cadastrar Cliente" widgetVar="cadastroClienteDialog" modal="true">
      Conteúdo
    </p:dialog>
</h:form>

You can check more examples and documentation at the link below: link

    
25.02.2017 / 23:10