0
votes

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.

1
I think you are trying to confirm an action after a button is clicked. For that, you should use the ConfirmDialog component provided by primefaces.cdaiga
yes, you right. But I need do custom actions. Thats why i chose this way. Thksbit.mind

1 Answers

0
votes

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