Just call the hide() and show() methods from p:commandLink.
p:commandLink value="open-close" onclick="dlg1.hide();dlg2.show();" />
primefaces use commandlink to hide one dialog and show another - Stack...
If you are using PrimeFaces, you can take advantage of PrimeFaces.monitorDownload and <p:fileDownload>. It is documented here.
action
actionListener
org.primefaces.model.StreamedContent
value
<p:fileDownload>
To prepare that StreamedContent, if your createPdf(studenToList) method returns a file, it would be as easy as following:
String mime = "application/pdf"; String name = "your-file-name.pdf"; File file = createPdf(studenToList); StreamedContent stream = new DefaultStreamedContent(file, mime, name);
onclick
commandButton
onclick="PrimeFaces.monitorDownload(startFaDwn, stopFaDwn);"
Finally, you have to provide your own implementation of startFaDown and stopFaDown. This is mine:
<script type="text/javascript"> function startFaDwn() { PF('FADownloadDlg').show(); } function stopFaDwn() { PF('FADownloadDlg').hide(); } </script>
As you can see, both functions open and hide a dialog as you want. You can name these functions as you want, and obviously it can do what you want, not only open/close dialog.
onComplete
ajax="false"
I use in Stream content only support inputStream so I useStreamedContent stream = new DefaultStreamedContent(getInpustream(file), mime, name) that dialog hide but download file not working, I remove ajax dialog box not hide and file not download
In File i set File file=new File("path of file stored"); and also I use InputStream stream = ((ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext()).getResourceAsStream("path of file stored"); both are not working
jsf - Primefaces commandButton download complete hide dialog - Stack O...
Finally i use javascript function :
function completed() { PF('eventDialog').hide(); PF('schedule').update(); }
and call with oncomplete.
If not working is because i need to place my script into my template juste before to close body i don't know why it doesn't work in other xhtml but now working.
THanks a lot to all.
jquery - JSF update schedule and hide dialog primefaces - Stack Overfl...
Basically the code should work by removing type="button" in the Register commandButton, in order to use an ajax request. the method #{register.Register} was not even called. Also remove the visible="true" in both dialogs
Just as a side note, in order to execute the backing method, JSF executes the validations rules, so you will see the confirmD dialog appear only when all the data in the form fulfill such validations
Primefaces hide and unhide dialog - Stack Overflow
Just call the hide() and show() methods from p:commandLink.
p:commandLink value="open-close" onclick="dlg1.hide();dlg2.show();" />
primefaces use commandlink to hide one dialog and show another - Stack...
enter code here
<p:column id="newwhc"> <f:facet name="header"> <h:outputLabel value="Search Fields"></h:outputLabel> </f:facet> <p:selectOneMenu styleClass="fdd180" id="newwdd" value="#{flxSearch.searchCriterion.whereClause}"> <f:selectItems value="#{flxSearch.whrClausDropdown}" /> </p:selectOneMenu> </p:column> <p:column id="newcoc"> <f:facet name="header"> <h:outputLabel value="Conditions"></h:outputLabel> </f:facet> <p:selectOneMenu id="newco" styleClass="fdd95" value="#{flxSearch.searchCriterion.operator}"> <f:selectItems id="newcriOperatorItms" value="#{flxSearch.operatorDropdown}" /> </p:selectOneMenu> </p:column> <p:column id="newcic"> <f:facet name="header"> <h:outputLabel value="Value"></h:outputLabel> </f:facet> <p:inputText id="newcriInpNm" rendered="#{!flxSearch.inputDate and !flxSearch.boolValue and !flxSearch.required}" styleClass="285 ftb" deferChangeEvent="true" value="#{flxSearch.searchCriterion.value}" maxlength="#{flxSearch.maxLength}" disabled="#{flxSearch.disableInput}" partialSubmit="true" labelValue="#{flxSearch.searchCriterion.label}" required="#{flxSearch.required}"> </p:inputText> <p:inputText id="newcriInpM" rendered="#{!flxSearch.inputDate and !flxSearch.boolValue and flxSearch.required }" value="#{flxSearch.searchCriterion.value}" maxlength="#{flxSearch.maxLength}" disabled="#{flxSearch.disableInput}" labelValue="#{flxSearch.searchCriterion.label}" required="#{flxSearch.required}"> </p:inputText> <p:selectOneMenu styleClass="fdd" id="newbldd" value="#{flxSearch.searchCriterion.value}" disabled="#{flxSearch.disableInput}" rendered="#{flxSearch.boolValue }"> <f:selectItems value="#{flxSearch.booleanDropdown}" /> </p:selectOneMenu> <p:calendar id="newcriDtNm" size="9" rendered="#{flxSearch.inputDate and !flxSearch.boolValue and !flxSearch.required }" disabled="#{flxSearch.disableInput}" showOn="button" value="#{flxSearch.searchCriterion.value}" labelValue="#{flxSearch.searchCriterion.label}"> </p:calendar> <p:calendar id="newcriDtM" size="9" rendered="#{flxSearch.inputDate and !flxSearch.boolValue and flxSearch.required }" disabled="#{flxSearch.disableInput}" value="#{flxSearch.searchCriterion.value}" enableChangeDetector="false" partialSubmit="true" labelValue="#{flxSearch.searchCriterion.label}" required="#{flxSearch.required}" showOn="button"> </p:calendar> </p:column> </p:dataTable> <p:fieldset legend="Combined By"> <h:panelGrid columns="2" cellpadding="10"> <p:selectOneRadio id="newSlctDrk" valueChangeListener="#{lookupSearch.getSelectedLogOpr}" value="#{lookupSearch.selLogOpr}" title="Combine all search criteria with AND or OR"> <f:selectItems id="newSlctDrkItms" value="#{lookupSearch.logicalOperators}" /> </p:selectOneRadio> </h:panelGrid> </p:fieldset> <h:panelGrid columns="3"> <p:commandButton value="Find" id="lkpfndDg" update="resultFldSet" actionListener="#{lookupSearch.search}"> </p:commandButton> <p:commandButton value="Clear" id="lkpClearDg" actionListener="#{lookupSearch.clear}" /> </h:panelGrid> <p:fieldset legend="Result" id="resultFldSet"> <p:dataTable binding="#{lookupSearch.lkpResultDataTable}" value="#{lookupSearch.searchResultsForPage}"></p:dataTable> </p:fieldset> <p:commandButton value="Select" id="lkpSltRec" update="customerCode,customerCode1,selectedCity1,selectedSate1" oncomplete="lpDialogVar.hide();insertSelectedValue();" actionListener="#{lookupSearch.selectValue}" /> </h:panelGrid> <!-- </h:form>--> </p:dialog> </h:panelGrid> </h:form>
Primefaces :textfield of parent component not updated when dialog hide...
enter code here
<p:column id="newwhc"> <f:facet name="header"> <h:outputLabel value="Search Fields"></h:outputLabel> </f:facet> <p:selectOneMenu styleClass="fdd180" id="newwdd" value="#{flxSearch.searchCriterion.whereClause}"> <f:selectItems value="#{flxSearch.whrClausDropdown}" /> </p:selectOneMenu> </p:column> <p:column id="newcoc"> <f:facet name="header"> <h:outputLabel value="Conditions"></h:outputLabel> </f:facet> <p:selectOneMenu id="newco" styleClass="fdd95" value="#{flxSearch.searchCriterion.operator}"> <f:selectItems id="newcriOperatorItms" value="#{flxSearch.operatorDropdown}" /> </p:selectOneMenu> </p:column> <p:column id="newcic"> <f:facet name="header"> <h:outputLabel value="Value"></h:outputLabel> </f:facet> <p:inputText id="newcriInpNm" rendered="#{!flxSearch.inputDate and !flxSearch.boolValue and !flxSearch.required}" styleClass="285 ftb" deferChangeEvent="true" value="#{flxSearch.searchCriterion.value}" maxlength="#{flxSearch.maxLength}" disabled="#{flxSearch.disableInput}" partialSubmit="true" labelValue="#{flxSearch.searchCriterion.label}" required="#{flxSearch.required}"> </p:inputText> <p:inputText id="newcriInpM" rendered="#{!flxSearch.inputDate and !flxSearch.boolValue and flxSearch.required }" value="#{flxSearch.searchCriterion.value}" maxlength="#{flxSearch.maxLength}" disabled="#{flxSearch.disableInput}" labelValue="#{flxSearch.searchCriterion.label}" required="#{flxSearch.required}"> </p:inputText> <p:selectOneMenu styleClass="fdd" id="newbldd" value="#{flxSearch.searchCriterion.value}" disabled="#{flxSearch.disableInput}" rendered="#{flxSearch.boolValue }"> <f:selectItems value="#{flxSearch.booleanDropdown}" /> </p:selectOneMenu> <p:calendar id="newcriDtNm" size="9" rendered="#{flxSearch.inputDate and !flxSearch.boolValue and !flxSearch.required }" disabled="#{flxSearch.disableInput}" showOn="button" value="#{flxSearch.searchCriterion.value}" labelValue="#{flxSearch.searchCriterion.label}"> </p:calendar> <p:calendar id="newcriDtM" size="9" rendered="#{flxSearch.inputDate and !flxSearch.boolValue and flxSearch.required }" disabled="#{flxSearch.disableInput}" value="#{flxSearch.searchCriterion.value}" enableChangeDetector="false" partialSubmit="true" labelValue="#{flxSearch.searchCriterion.label}" required="#{flxSearch.required}" showOn="button"> </p:calendar> </p:column> </p:dataTable> <p:fieldset legend="Combined By"> <h:panelGrid columns="2" cellpadding="10"> <p:selectOneRadio id="newSlctDrk" valueChangeListener="#{lookupSearch.getSelectedLogOpr}" value="#{lookupSearch.selLogOpr}" title="Combine all search criteria with AND or OR"> <f:selectItems id="newSlctDrkItms" value="#{lookupSearch.logicalOperators}" /> </p:selectOneRadio> </h:panelGrid> </p:fieldset> <h:panelGrid columns="3"> <p:commandButton value="Find" id="lkpfndDg" update="resultFldSet" actionListener="#{lookupSearch.search}"> </p:commandButton> <p:commandButton value="Clear" id="lkpClearDg" actionListener="#{lookupSearch.clear}" /> </h:panelGrid> <p:fieldset legend="Result" id="resultFldSet"> <p:dataTable binding="#{lookupSearch.lkpResultDataTable}" value="#{lookupSearch.searchResultsForPage}"></p:dataTable> </p:fieldset> <p:commandButton value="Select" id="lkpSltRec" update="customerCode,customerCode1,selectedCity1,selectedSate1" oncomplete="lpDialogVar.hide();insertSelectedValue();" actionListener="#{lookupSearch.selectValue}" /> </h:panelGrid> <!-- </h:form>--> </p:dialog> </h:panelGrid> </h:form>
Primefaces :textfield of parent component not updated when dialog hide...
Finally, i have got the solution . The exception i have encountered is because of the form tag . The ajax event fired from the dialog is not able to find the component outside the form . So i have enclosed the page with the form tag.here is the code snippet.
Primefaces :textfield of parent component not updated when dialog hide...
Basically the code should work by removing type="button" in the Register commandButton, in order to use an ajax request. the method #{register.Register} was not even called. Also remove the visible="true" in both dialogs
Just as a side note, in order to execute the backing method, JSF executes the validations rules, so you will see the confirmD dialog appear only when all the data in the form fulfill such validations
Primefaces hide and unhide dialog - Stack Overflow
Finally, i have got the solution . The exception i have encountered is because of the form tag . The ajax event fired from the dialog is not able to find the component outside the form . So i have enclosed the page with the form tag.here is the code snippet.
Primefaces :textfield of parent component not updated when dialog hide...
What is the version of primefaces?
if is the version 5.0 try with :
<p:confirmDialog header="Bid" severity="alert" widgetVar="dlg" showEffect="bounce" hideEffect="explode" global="true"> <p:commandButton value="Yes" actionListener="#{bidsBean.acceptBid}" oncomplete="PF('dlg').hide()" icon="ui-icon-check" ajax="true"/> <p:commandButton value="No" onclick="PF('dlg').hide();" type="button" icon="ui-icon-close"/></p:confirmDialog>
jsf - Primefaces dialog hide method breaks my css - Stack Overflow
enter code here
<p:column id="newwhc"> <f:facet name="header"> <h:outputLabel value="Search Fields"></h:outputLabel> </f:facet> <p:selectOneMenu styleClass="fdd180" id="newwdd" value="#{flxSearch.searchCriterion.whereClause}"> <f:selectItems value="#{flxSearch.whrClausDropdown}" /> </p:selectOneMenu> </p:column> <p:column id="newcoc"> <f:facet name="header"> <h:outputLabel value="Conditions"></h:outputLabel> </f:facet> <p:selectOneMenu id="newco" styleClass="fdd95" value="#{flxSearch.searchCriterion.operator}"> <f:selectItems id="newcriOperatorItms" value="#{flxSearch.operatorDropdown}" /> </p:selectOneMenu> </p:column> <p:column id="newcic"> <f:facet name="header"> <h:outputLabel value="Value"></h:outputLabel> </f:facet> <p:inputText id="newcriInpNm" rendered="#{!flxSearch.inputDate and !flxSearch.boolValue and !flxSearch.required}" styleClass="285 ftb" deferChangeEvent="true" value="#{flxSearch.searchCriterion.value}" maxlength="#{flxSearch.maxLength}" disabled="#{flxSearch.disableInput}" partialSubmit="true" labelValue="#{flxSearch.searchCriterion.label}" required="#{flxSearch.required}"> </p:inputText> <p:inputText id="newcriInpM" rendered="#{!flxSearch.inputDate and !flxSearch.boolValue and flxSearch.required }" value="#{flxSearch.searchCriterion.value}" maxlength="#{flxSearch.maxLength}" disabled="#{flxSearch.disableInput}" labelValue="#{flxSearch.searchCriterion.label}" required="#{flxSearch.required}"> </p:inputText> <p:selectOneMenu styleClass="fdd" id="newbldd" value="#{flxSearch.searchCriterion.value}" disabled="#{flxSearch.disableInput}" rendered="#{flxSearch.boolValue }"> <f:selectItems value="#{flxSearch.booleanDropdown}" /> </p:selectOneMenu> <p:calendar id="newcriDtNm" size="9" rendered="#{flxSearch.inputDate and !flxSearch.boolValue and !flxSearch.required }" disabled="#{flxSearch.disableInput}" showOn="button" value="#{flxSearch.searchCriterion.value}" labelValue="#{flxSearch.searchCriterion.label}"> </p:calendar> <p:calendar id="newcriDtM" size="9" rendered="#{flxSearch.inputDate and !flxSearch.boolValue and flxSearch.required }" disabled="#{flxSearch.disableInput}" value="#{flxSearch.searchCriterion.value}" enableChangeDetector="false" partialSubmit="true" labelValue="#{flxSearch.searchCriterion.label}" required="#{flxSearch.required}" showOn="button"> </p:calendar> </p:column> </p:dataTable> <p:fieldset legend="Combined By"> <h:panelGrid columns="2" cellpadding="10"> <p:selectOneRadio id="newSlctDrk" valueChangeListener="#{lookupSearch.getSelectedLogOpr}" value="#{lookupSearch.selLogOpr}" title="Combine all search criteria with AND or OR"> <f:selectItems id="newSlctDrkItms" value="#{lookupSearch.logicalOperators}" /> </p:selectOneRadio> </h:panelGrid> </p:fieldset> <h:panelGrid columns="3"> <p:commandButton value="Find" id="lkpfndDg" update="resultFldSet" actionListener="#{lookupSearch.search}"> </p:commandButton> <p:commandButton value="Clear" id="lkpClearDg" actionListener="#{lookupSearch.clear}" /> </h:panelGrid> <p:fieldset legend="Result" id="resultFldSet"> <p:dataTable binding="#{lookupSearch.lkpResultDataTable}" value="#{lookupSearch.searchResultsForPage}"></p:dataTable> </p:fieldset> <p:commandButton value="Select" id="lkpSltRec" update="customerCode,customerCode1,selectedCity1,selectedSate1" oncomplete="lpDialogVar.hide();insertSelectedValue();" actionListener="#{lookupSearch.selectValue}" /> </h:panelGrid> <!-- </h:form>--> </p:dialog> </h:panelGrid> </h:form>
Primefaces :textfield of parent component not updated when dialog hide...
Finally, i have got the solution . The exception i have encountered is because of the form tag . The ajax event fired from the dialog is not able to find the component outside the form . So i have enclosed the page with the form tag.here is the code snippet.