This tutorial tries to solve a recurring need in most developments with JSF.
Certain actions require confirmation at the time of completion.
Let’s see an example:
A user wants to delete a previously selected record in a list, click on the Delete button and a confirmation message is displayed, if he accepts he proceeds with the deletion if he cancels he returns to the list without changes.
This operation should not require complexity, and a simple and elegant way to solve it is the one we propose.
Through the ICEFACES PanelConfirmation component we show a panel directly associated with the button.
One of the great advantages is that said confirmation panel is completely transparent to the controller.
- Hardware: MacBook Pro 15 ‘(2.8 GHz Intel Core 2 Duo, 4GB DDR3 SDRAM).
- Operating System: Mac OS X Snow Leopard 10.6.3.
- NVIDIA GeForce 9600M GT 512Mb.
- Toshiba 500 Gb. 5400r.pm
3. Description of the component
In ICEFACES we have the commandButton component whose panelConfirmation attribute gives us the possibility of assigning a confirmation panel
that we define in the page itself. This panel contains a series of attributes that allow us to define the values of the blocking message fields.
Another great utility of thisConfirmation panel is its total compatibility with the immediate attribute that allows us to skip the
JSF validations .
Here we have the component page.
4. Practical example
In the example proposed at the beginning of this tutorial (delete button), when we delete, we carry out an action that does not require the validation of the form, since to eliminate a record it should not be necessary to comply with the valications.
On the other hand, a save button requires reaffirmation and validation of the data.
Save button with a confirmation panel pop-up, the immediate attribute by default takes value “false”.
Delete button with a confirmation panel pop-up.
Definition of the panels associated with the previous buttons.
Capture of the Validation panel associated with the delete button.
After this brief introduction to the component, we see how simple it is to validate actions in a way that is totally transparent to the controller.
These panels are very simple to define and link to the buttons, providing internationalization and extra functionality.
The post Validation of actions on buttons in Jsf with Icefaces appeared first on Target Veb.