0

i need help with this. I have a 'form' which call a p:dialog through p:commandButton. That p:dialog include other p:commandButton, but that second button does not take any action, which is weird for me, because the first button works fine.

The code:

<ui:define name="body">            
        <br/>
        <br/>
        <br/>
        <p:ajaxStatus onstart="PF('statusDialog').show()" onsuccess="PF('statusDialog').hide()" />
        <p:dialog widgetVar="statusDialog" modal="true" draggable="false" closable="false" resizable="false" showHeader="false">
            <p:graphicImage value="/resources/Images/ajax-loader.gif" alt="Por favor espere..." />
        </p:dialog>

        <h:form id="BuscarEmpresaForm">
            <h:panelGroup id="display">
                <h:panelGrid columns="2" style="margin-left: 10px;">
                    <p:outputLabel value="#{bundle.BuscarEmpresaBuscarLabel}" />  
                    <h:outputLabel/>
                    <h:selectOneRadio id="idBusquedaRadio" value="#{cupoController.radioButtonBusqueda}">
                        <f:selectItem itemLabel="#{bundle.BuscarEmpresaCodigoLabel}" itemValue="Codigo" />
                        <f:selectItem itemLabel="#{bundle.BuscarEmpresaNombreLabel}" itemValue="Nombre" />
                    </h:selectOneRadio>
                    <h:outputLabel/>
                    <p:inputText id="empresa" value="#{cupoController.empresaTextoBusqueda}" required="true" requiredMessage="El campo es requerido"/>  

                    <!--THIS BUTTON WORKS-->

                    <p:commandButton value="Buscar" actionListener="#{cupoController.prepareCreateEmpresa()}" action="#{cupoController.searchEmpresa()}" oncomplete="PF('dlg1').show();" update=":confirmDialogEmpresa">                            
                    </p:commandButton>   
                    <p:message  for="empresa"/>

                </h:panelGrid>
            </h:panelGroup>
        </h:form>
        <p:dialog id="dialog1" header="Mensaje" widgetVar="dlg1" minHeight="40" modal="true" appendTo="@(body)">
            <h:form id="confirmDialogEmpresa">
                <h:panelGroup id="display">
                    <h:panelGrid columns="2" rendered="#{cupoController.selectedEmpresa.codcor != null}">
                        <p:outputLabel value="Empresa encontrada, Continuar?"/>
                        <h:outputLabel/>                             
                        <p:outputLabel value="Nombre: #{cupoController.selectedEmpresa.razonsocial}"/> 
                        <h:outputLabel/> 
                        <p:outputLabel value="RUC: #{cupoController.selectedEmpresa.ruc}"/> 
                        <h:outputLabel/> 

                         <!--THIS BUTTON DOES NOT WORK-->

                        <p:commandButton value="Si" action="#{cupoController.buscarCupo}" icon="ui-icon-check"/>
                        <p:commandButton value="No" onclick="dlg1.hide();" icon="ui-icon-close" update="@none"/>  
                    </h:panelGrid>
                    <h:panelGrid columns="2" rendered="#{cupoController.selectedEmpresa.codcor == null}" > 
                        <p:outputLabel value="Empresa no encontrada"/>
                        <h:outputLabel/> 
                        <p:messages />
                        <h:outputLabel/>
                        <p:commandButton value="Aceptar" onclick="dlg1.hide();" icon="ui-icon-close" update="@none"/>
                    </h:panelGrid>
                </h:panelGroup>
            </h:form>
        </p:dialog>

    </ui:define> 

I have done some attempts replacing p:commandButton for h:commandButton but have same results.

An image showing what code outs

Thanks in advance.

bit.mind
  • 23
  • 1
  • 6
  • I think you are trying to confirm an action after a button is clicked. For that, you should use the [ConfirmDialog](http://www.primefaces.org/showcase/ui/overlay/confirmDialog.xhtml) component provided by primefaces. – cdaiga Dec 28 '16 at 01:55
  • yes, you right. But I need do custom actions. Thats why i chose this way. Thks – bit.mind Jan 14 '17 at 22:36

1 Answers1

0

I found the problem and is related to the topic: Backing beans (@ManagedBean) or CDI Beans (@Named)?

In my case i was confused. I was mixing CDI annotations with JSF annotations in the managed bean related, producing a strange behavior. Finally i have fixed letting just JSF annotations.

Core: JSF 2.0, PrimeFaces 5.0, GlassFish 4.1

Community
  • 1
  • 1
bit.mind
  • 23
  • 1
  • 6