0

I have a form with serveral Dialog, one of them call a function with parameter, but I don't know why is not working. Other dialog are working perfectly. The dialog with parameters:

<p:dialog widgetVar="windowsConfirmOperation" position="center middle" resizable="false"
header="¡Warning!" closable="false" showEffect="fade" hideEffect="fade" 
id="idWindowsConfirmOperation" modal="true">
<p:panel>
     <div class="DispBlock Responsive100">
        <p:outputLabel value="Are you sure?" 
            escape="false"/>
     </div>
 </p:panel> 
 <div class="DispBlock ui-contenedor-botones-accion Fright"> 
     <p:commandButton value="YES"                            
         oncomplete="PF('windowsConfirmOperation').hide();"
        update="@form" process="@form"
        action="#{queryView.confirmOperation('true')}">
     </p:commandButton> 
     <p:commandButton value="NO"                            
         oncomplete="PF('windowsConfirmOperation').hide();"
        update="@form" process="@form" 
        action="#{queryView.confirmOperation('false')}">
     </p:commandButton>
 </div>
</p:dialog>

And my view class called QueryView:

@SessionScoped
@ManagedBean
public class QueryView {        

        ....

        public void confirmOperation(String confirm) {
        if ("true".equals(confirm)) {
            doSomeThing();
        }
    }       
}

I debug but the dialog never call the function. I changed parameters of Boolean to String but not working. What am I doing wrong?

Regards.

Chema
  • 67
  • 4
  • 17

1 Answers1

0

Finally I modified my logic and now the code works.

<p:dialog widgetVar="windowsConfirmOperation" position="center middle" resizable="false"
header="¡Warning!" closable="false" showEffect="fade" hideEffect="fade" 
id="idWindowsConfirmOperation" modal="true">
<p:panel>
     <div class="DispBlock Responsive100">
        <p:outputLabel value="Are you sure?" 
            escape="false"/>
     </div>
 </p:panel> 
 <div class="DispBlock ui-contenedor-botones-accion Fright"> 
     <p:commandButton value="YES"                            
         oncomplete="PF('windowsConfirmOperation').hide();" process="@this"
        action="#{queryView.confirmOperation}">
     </p:commandButton> 
     <p:commandButton value="NO"                            
        onclick="PF('windowsConfirmOperation').hide();"
        >
     </p:commandButton>
 </div>
</p:dialog>
  1. I have changed the param process="@form" for process="@this". I only process the button not all form.
  2. How NO button only close the dialog I changed it. Now only use onclick function.
  3. How only the YES button use the function, now I don't need parameters. So my function changed to:

    public void confirmOperation() {
       doSomeThing();
    }
    

Edit: If I pass a Boolean works too.

action="#{queryView.confirmOperation('true'}">

and java file

public void confirmOperation(Boolean something) {
   doSomeThing();
}

With these changes my code works fine.

Regards

Chema
  • 67
  • 4
  • 17