I work on primefaces 6.0 and I have a dialog box, called by a command button, I have several element in this dialog box and 2 command button, one is for closing the dialog box, the other (commandButton id="enableDisableButton") is an option of my program. It must display True or False, like a select boolean button. But when I click on the button, it close my dialog box and I don't understand why !
<p:dialog header="Modal Dialog" widgetVar="rulesDialogBox" modal="true"
width="540" height="400" minWidth="540" minHeight="400"
dynamic="true">
<p:panelGrid columns="1" style="border:none !important;">
<h:outputText id="selectedFile" value="#{eventConfigurationView.loadedFile}"/>
<p:fileUpload label="#{msgs.rule_browse}" fileUploadListener="#{eventConfigurationView.handleFileUpload}" mode="advanced"
update="selectedFile" auto="true" sizeLimit="100000" allowTypes="/(\.|\/)(xls)$/"
minHeight="30px" minWidth="110px"
style="margin-bottom:20px;" />
<!-- allowTypes="/(\.|\/)(xls|csv|xlsx)$/" -->
<p:commandButton value="#{msgs.download}" ajax="false" onclick="PrimeFaces.monitorDownload(start, stop);" style="margin:5px;"
minHeight="30px" minWidth="110px">
<p:fileDownload value="#{eventConfigurationView.file}" />
</p:commandButton>
<p:commandButton id="enableDisableButton"
value="#{eventConfigurationView.myEnable}" style="margin:5px;"
action="#{eventConfigurationView.buttonAction}"
ajax="false"
minHeight="30px" minWidth="110px">
</p:commandButton>
<p:commandButton value="#{msgs.close}" onclick="PF('rulesDialogBox').hide();" type="button" style="margin:5px;"
minHeight="30px" minWidth="110px"/>
</p:panelGrid>
</p:dialog>
public void buttonAction() {
System.out.println("buttonAction");
}
Supposing you refer to p:commandButton id="enableDisableButton"
you have disabled ajax on it via ajax="false"
.
This reloads the entire page on click. As the initial state of the p:dialog
is hidden, it looks like the dialog disappers while in fact the page has reloaded completely.