在jsf中创建动态确认对话框 [英] create dynamic Confirm dialog in jsf

查看:56
本文介绍了在jsf中创建动态确认对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建动态确认对话框.我有一个动态创建的CommandButton.因此,当按下时,将显示confirmDialog.我不知道如何在按下CommandButton时显示它.

I need create dynamic confirmDialog. I have a dynamicallly created CommandButton. So when it press, confirmDialog will show. I do not know how to show it on CommandButton pressed.

推荐答案

您的按钮应如下所示:

<p:commandLink oncomplete="confirmation.show()"  
  action="#{campagneComtroller.messageDeleteCam1(c)}" 
  update=":frmDlgDel:confirmDialog">
  <p:graphicImage value="/image/delete.png" height="20" width="20"/>
</p:commandLink>

您的ConfirmDialog应该是这样的:

Your confirmDialog should be like this:

<h:form id="frmDlgDel">
            <p:confirmDialog id="confirmDialog" 
                    message="#{campagneComtroller.messageDeleteCam1}"  
                       header="#{bundles.messages['message.SupprimerGeneral']}" severity="alert" widgetVar="confirmation">  
               <p:commandButton id="confirm" value="#{bundles.messages['message.OuiSure']}" oncomplete="confirmation.hide()" update=":formCam :frmDlgDel"
                        actionListener="#{campagneComtroller.deleteCam1()}" />  
               <p:commandButton id="decline" value="NonPasEncore" onclick="confirmation.hide()" type="button" />   
           </p:confirmDialog>
        </h:form>

您的Java代码应如下所示:

Your java code should be like this:

   public void messageDeleteCam1(Cam cam) {
conditionVerified = true; // ... you can put here your treatments
            if (conditionVerified) {
                messageDeleteCam1 = "this cam is bla bla bla ";
            } else {
                messageDeleteCam1 = "are you sure to delete this cam ?";
            }
        }

注意事项:我们在这里使用了 oncomplete + update ,这就是为什么我们可以在java处理后在confirmDialog中看到差异.

NB: we have used here oncomplete + update, that's why we could see the difference in the confirmDialog after java treatments.

这篇关于在jsf中创建动态确认对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆