Wednesday, May 27, 2009

Icefaces PanelConfirmation usage example

Hello there...

recently we needed to add confirmation dialogs on some of the user events of our Icefaces application. Luckily, since version 1.8, Icefaces comes with a new component called PanelConfirmation which does the job pretty well and easy.

As I could not find any straight example I decided to write here a little code snippet.
To define the confirmation panel in the very page you need to write the following:


<ice:panelConfirmation id="confirmDeletion"
acceptLabel="OK"
cancelLabel="Cancel"
message="You are about to delete. Are you sure?"
title="Confirm delete"
draggable="false"
/>

Now you need to bind the dialog with the actions you want to confirm. To do so there is a new property in commandButton and commandLink components. Note the id in the above declaration, it is important to further bind the component. As usual, you will need this id to be unique in the scope.


<ice:commandButton actionListener="#{myActionListener}" value="Remove" panelConfirmation="confirmDeletion" />


In the panelConfirmation property you need to put the id of the dialog.

Regrettably there is still not support for this on the rest of the components that trigger user events, such us menuItems. I don't know if this is coming next or there is any implementation reason that prevents the rest of the components to bind to confirmation dialogs.

I still haven't checked whether you can change the dialog properties binding it to it's Java component when the action fires, as it is delayed until the user accepts in the very panel, nor if the dialog properties can be calculated values as in the rest of the components.

In theory you can define the panel anyway in the application as far as it is defined in the context with the proper id.

Hope this helps!

5 comments:

Anonymous said...

Thank you, this clear information helped me!

Pablo Barrachina said...

Thank you very much!! This is a very useful post!

david said...

Hi.

Looking at your example I see yo bind to a commandButton, right?, but If I would like to show it from my code as we usually do with PopupBean calling popupBean.setModalRendered(true); which show it, is this possible, because I have no see an object like PanelConfirmation.java..

Thanks

Zoltan Altfatter said...

After clicking on a continue button on a panelConfirmation I have to show another panelConfirmation, but then on the second panelConfirmation how to put an action method?

jegg said...

Good one!