It works in the situation that you want to ask something for user before really do it. For example, we can think about the situation when the user will delete all clients. It’s better ask him before do that, like as “Are you sure?”.
<h:commandLink onclick="if (! confirm('Are you sure?)) return false" action="#{myController.removeAllClients()}"> <i class="glyphicon glyphicon-check"></i> Remove All Clients </h:commandLink>