0

Submit button is pressed the bean first checks for valid values, if it fails validation a dialog is presented. While the process is running another session submits a button press and the bean checks the flag and need to present a different dialog.

Is there away to have a single commandButton interact with two different confirmDialogs, commandButton "update" interacts with the confirmDialog

The main difference with my issue verse the other examples/solutions, there is only one button. And the update="confirmValid" on the submit button is only working for the first button push.

The bean is called successfully from "second" button press, the forceRequest method doesn't display the dialog

<p:commandButton id="myButton" update="confirmValid growl"
                 value="Submit"
                 actionlistener="#{message.sendMessage}"
...
/>

This dialog is presented for display when the request is invalid

<p:confirmDialog header="#{message.invalidValuesHdr}"
   id="confirmValidData" message="#{message.invalid}"
   wigdetVar="confirmValidData">
    <p:commandButton value="Ok" update="growl" oncomplete="PF('confirmValidData').hide()"
</p:confirmDialog>

This dialog is presented when the process flag has been updated

<p:confirmDialog header="#{message.forceRequestHdr}"
   id="confirmValidData" message="#{message.invalid}"
   wigdetVar="confirmForce">
    <p:commandButton value="Ok" update="growl" oncomplete="PF('confirmForce').hide()"
</p:confirmDialog> 

Bean:

@ViewScoped 

@Override 
public void sendMessage() {
  if (....)
    forceRequest();

}

public void forceRequest(){
   FacesMessage message = new 
   FacesMessage(FacesMessage.SEVERITY_INFO,"Message Title", "Message body");
   RequestContext.getCurrentInstance().showMessageInDialog(message);
}

Displays a dialog the method below does nothing, which is the issue

public void forceRequest(){
  RequestContext context = RequestContext.getCurrentInstance();
  context.openDialog("Confirm");
  context.execute("PF('confirmForce').jq.click();");
}

faces-config.xml is updated

Steve
  • 31
  • 4
  • 1
    Take a look here: https://www.primefaces.org/showcase/ui/ajax/remoteCommand.xhtml or use validators and skip them with a flag: https://stackoverflow.com/questions/14335610/jsf-skip-required-validation-without-immediate-true – stefan-dan Oct 29 '21 at 07:38
  • I'm constrained to using PrimeFaces 6.1, the remoteCommand example requires Primefaces.current – Steve Nov 04 '21 at 13:10

1 Answers1

0
public void forceRequest(){
  RequestContext.getCurrentInstance().execute("PF('confirmForce').show();");
}

Above was the solution and now on to the bean

Steve
  • 31
  • 4