如何添加确认对话框

Sur*_*rya 7 jsf-2

我想在编辑行时添加确认对话框,或者如何在任何操作时提示用户确认.我应该在下面的代码中使用哪个对话框.

<h:commandLink value="EditPage" action="#{countryBean.editCountryByCountryCode(true)}"  class="edit_icon" >
             <f:setPropertyActionListener target="#{countryBean.editCountryId}" value="#{countryLang.countryCode}" />
             </h:commandLink> 
Run Code Online (Sandbox Code Playgroud)

小智 23

一个简单的方法,使用简单的javascript:

<h:commandLink onclick="if (! confirm('Really want to do that?')) return false"
value="EditPage" action="#{countryBean.editCountryByCountryCode(true)}"  class="edit_icon" >
   <f:setPropertyActionListener target="#{countryBean.editCountryId}" value="#{countryLang.countryCode}" />
</h:commandLink> 
Run Code Online (Sandbox Code Playgroud)

  • 较短的"返回确认('真的想这样做?')"也是正确的. (4认同)

SRy*_*SRy 5

<p:confirm/>为此,您可以使用 Primefaces Confirm 对话框 。您可以在此处找到示例展示。