myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard Yee" <richard.k....@gmail.com>
Subject [Trinidad] Executing a JavaScript function when a validation error occurs
Date Fri, 25 Jan 2008 23:00:04 GMT
Hi,
I'm displaying a "Loading..." message to my user after they press a
commandButton by having an onclick event fire a JavaScript function. This
works fine except for when there is a validation error. In this case, the
"Loading..." message is still displayed. What I would like to have happen is
to hide the Loading message when this occurs. I tried setting the onload
event in the tr:document tag to clearProgress() but it didn't get called. Is
there another way to execute a JavaScript function when a validation error
occurs?

Thanks,
Richard


.jspx
....
<tr:commandButton text="Continue" action="#{myBacking.continueAction}"
onclick="showProgress()"/>
<tr:outputText id="loadProgress" inlineStyle="text-align:centered;
background-color: red; display: none;" value="Loading..."/>
....

JavaScript:
function showProgress() {
  var progressElem = document.getElementById("loadProgress");
  progressElem.style.display = 'inline';
}

function clearProgress() {
  var progressElem = document.getElementById("loadProgress");
  progressElem.style.display = 'none';
}

Mime
View raw message