我有一个导入功能,它将解析包含文档版本信息的XML文件并将其保存到数据库中。如果用户尝试上传已经存在的版本,我需要显示确认对话框,如“您已经存在的版本是否要覆盖..?”好的,取消。如何显示支持bean的确认对话框(Primefaces)
我正在使用Mozarra 2.0.3,Prime会面2.2 RC2,Glass Fish 3,我正在尝试这种方式。
<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);
}
}
当我点击 “OK” 的动作不点火。上述代码中是否有错误?
你到目前为止尝试过什么?只需显示一个对话框就可以使用Primefaces'p:dialog'。 – 2011-05-09 11:21:50
嗨马特,我需要从服务器端做到这一点。如果(VersionExists){显示一个确认对话框。} – neni 2011-05-12 09:03:14