2014-04-19 105 views
0

我有一个确认消息框,当用户点击保存按钮时出现,它只是简单地要求他们确认他们想要保存,但即使全部弹出验证失败,有没有办法,只显示消息框,如果所有的验证是成功的如何停止弹出消息确认验证是否失败

<p> 
     <p:commandButton value="#{bundle.buttonSaveMark}" icon ="ui-icon-disk" update="displayMark :growl" oncomplete="PF('dlg').show()" /> 
    </p> 
    <p:dialog header="Confirm Mark" widgetVar="dlg" showEffect="fold" hideEffect="fold"> 
     <h:panelGrid id="displayMark" columns="2" cellpadding="5"> 
      <h:outputText value="Mark to be submitted: " /> 
      <h:outputText value="#{selectedValue}"/> 
      <p:commandButton id="save" 
          value="#{bundle.buttonSave}" 
          actionListener ="#{markingBean.editMark}" 
          update="Navigation :growl" 
          icon="ui-icon-disk" 
          oncomplete="PF('nav').show()"/> 
     </h:panelGrid> 
    </p:dialog> 

    <p:dialog header="Navigation" widgetVar="nav" showEffect="fold" hideEffect="fold"> 
     <h:panelGrid id="Navigation" columns="2" cellpadding="5"> 
      <h:outputText value="Return to this project's marking page: " /> 
      <p:button id="go" 
         value="#{bundle.buttonProjMark}" 
         outcome ="/lecturer/marking/marking-index.xhtml?edit_id=#{markingBean.markToEdit.id}" 
         icon="ui-icon-clipboard"/> 
      <h:outputText value="Return to staff homepage: " /> 
      <p:button id="staffHome" 
         value="#{bundle.buttonStaffHome}" 
         outcome ="/index" 
         icon="ui-icon-home"/> 
     </h:panelGrid> 
    </p:dialog> 

是按钮,然后确认

回答

1

您可以

更新从Java代码THA导航对话框
RequestContext.getCurrentInstance().update("Navigation"); 

而且从Java代码添加callBackParam:

RequestContext.getCurrentInstance().addCallbackParam("showDialog",true); 

上面的代码添加到您的markingBean.editMark行动。如果验证失败,您的操作将不会被调用,所以callbackParam将不会被添加,这样对话框将不会出现。

在客户端应该创建其处理请求完成一个js函数:

function handle(args) { 
    if (data != null && data.showDialog) { 
     PF('nav').show() 
    } 
} 

,按钮上:

oncomplete="handle(args);" 
+0

如果此解决方案是适合你的,不是请接受anwser 。所以其他人会知道这是一个封闭的问题。谢谢。 – Tushee