I would like to customize the presentation of faces messages.
For this,
<h:inputText id="name" required="true" />
when validation is failed, then it will be shown in a
<h:message for="name" />
However, I would like to customize the presentation call JS as follows:
<div class="notification"></div>
function showNotification(msg){
$(".notification").html(msg);
$(".notification").fadeIn(1000, function(){
timeout = setTimeout(function(){
$(".notification").fadeOut(1000);
}, 5000);
});
}
How can I achieve this?
You can use
FacesContext#getMessageList()to get the messages in the view, if necessary the ones for a specific client ID. You can iterate over them in aui:repeat. Each item is aFacesMessagewhich has several getters. You can display any HTML in the message unescaped by using<h:outputText escape="false">.So, in a nutshell:
(in the above example, I assume that your form has
id="form")Or, if that HTML help link is actually not part of the message, then so: