Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add confirmation dialog

Tags:

jsf-2

I want to add confirmation dialog befor editing a row or how to prompt user a confirmation befor any action. which dialog should I use for below code.

<h:commandLink value="EditPage" action="#{countryBean.editCountryByCountryCode(true)}"  class="edit_icon" >
             <f:setPropertyActionListener target="#{countryBean.editCountryId}" value="#{countryLang.countryCode}" />
             </h:commandLink> 
like image 548
Surya Avatar asked Oct 14 '13 14:10

Surya


People also ask

How do you display a confirmation dialog when clicking an a link?

In the most simple way, you can use the confirm() function in an inline onclick handler.

How do you make a confirmation pop up in HTML?

The confirm() method displays a dialog box with a message, an OK button, and a Cancel button. The confirm() method returns true if the user clicked "OK", otherwise false .

How do I change the button text in confirm box?

JavaScript users can create the confirm box using the . confirm() method, which contains the confirmation message string, ok, and cancel button. The programmer can't change the confirm box style and button label if they use the default confirm box.

What is the difference between confirm and alert method?

Alert box is used if we want the information comes through to the user. Confirm box is used if we want the user to verify or accept something. 2. You need to click “OK” to proceed when an alert box pops up.


2 Answers

A simple way, using a simple 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> 
like image 160
andremonteiro Avatar answered Sep 20 '22 20:09

andremonteiro


You can use Primefaces Confirm dialog <p:confirm/> for this purpose. You can find example showcase here.

like image 38
SRy Avatar answered Sep 22 '22 20:09

SRy