You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Yannis BRES <ya...@gmail.com> on 2010/01/18 10:50:30 UTC
Re: Server side error messages need to be cleared when resubmitted
the page to prevent duplicate display
Hi !
We also faced this issue, and the quickest / less dirty way we found to
address it was to write a small Java Script method, that gets called on all
form submissions using onsubmit :
<tr:form id="smc_domain_form"
onsubmit="SMCClearAllMsg();return true;">
This method first removes the global messages that are in displayed by
<h:messages
id="smc_global_messages" globalOnly="true" .../> and then removes whatever
non global messages that can appear on the page :
function SMCClearAllMsg()
{
// remove global messages (with its list bullet)
var global_msg= document.getElementById("smc_global_messages");
if (global_msg != null)
{
global_msg.style.display='none';
}
// remove each message but do not remove client-side validation from
trinidad.
// Note: only our messages where we set class=OraInlineErrorText are
involved
// message generated by client-side validation usually have class=x9e
(compacted).
var spans = document.getElementsByTagName("span");
for ( var i = 0; i < spans.length; i++)
{
if ( (spans[i].className == "OraInlineErrorText")
&& (spans[i].parentNode.className !=
"af_panelFormLayout_message-cell")
&& (spans[i].parentNode.className !=
"AFComponentMessageCell"))
{
spans[i].style.display = 'none';
}
}
}
Of course, the question remains : shouldn't this be done by Trinidad ?
Hope this helped,
Yannis