I have an import function which will parse the XML file which contains the version information of the document and save it in database. If user try to upload the already existing version, I need to show the confirmation dialog like " Version already exists do you wants to overwrite..?" ok, Cancel.
I am using Mozarra 2.0.3, Prime faces 2.2 RC2, Glass Fish 3 and I am trying this way.
<h:form id="conDialog">
<p:commandButton value="getConfirmMsg" update="conDialog" action="#{buttonBean.getConfirmMsg()}"
oncomplete="confirmation.show()"/>
<p:growl id="messages1" globalOnly="true"/>
<p:confirmDialog message="Version already exists. Do you want to override it?"
rendered="#{buttonBean.showConfirm}"
header="Version already exist" severity="alert" widgetVar="confirmation">
<p:commandButton value="OK" update="messages1" oncomplete="confirmation.hide()"
action="#{buttonBean.overrideVersion}" />
<p:commandButton value="Cancel" onclick="confirmation.hide()" type="button" />
</p:confirmDialog>
</h:form>
BackingBean
@ManagedBean
@RequestScoped
public class ButtonBean {
boolean showConfirm = false;
public boolean isShowConfirm() {
return showConfirm;
}
public void setShowConfirm(boolean showConfirm) {
this.showConfirm = showConfirm;
}
public void overrideVersion() {
System.out.println("Version alrady exists...Overriding...");
FacesMessage msg = new FacesMessage("Action is successful");
FacesContext.getCurrentInstance().addMessage(null, msg);
}
public void getConfirmMsg() {
System.out.println("Inside getConfirmMsg()....");
showConfirm = true;
System.out.println("showConfirm: " + showConfirm);
}
}
When I click on "OK" the action is not firing. Is there any mistake in the above code?
p:dialog
. – Matt Handy