When my page is loaded I execute the following JS script, which I use to display a popup saying (please wait...) when any form is submitted.
jQuery(function(){
jQuery("form").submit(function(){jQuery('#wait-link').trigger('click');return true;});
});
This works fine when using h:commandButton tag, however when I use the h:commandLink tag it doesn't work because the form is submitted by java script (from the file jsf.js in the jar jsf-impl.jar) as shown below
mojarra.jsfcljs = function jsfcljs(f, pvp, t) {
mojarra.apf(f, pvp);
var ft = f.target;
if (t) {
f.target = t;
}
f.submit();
f.target = ft;
mojarra.dpf(f);
};
To solve this problem I copied the jsf.js file under WEB-INF/resources/javax.faces/jsf.js and modified it to trigger the form submit method using jQuery. This works fine but:
1) I don't like the fact that I am touching the jsf.js file since it may change in newer releases of JSF.
2) I don't like the fact that I am using jQuery inside the jsf.js file.
Is there a better solution to solve this problem?