The JSF form is not submitted when the form is disabled by JavaScript.

This is the submit button:

<h:commandButton 
    actionListener="#{regBean.findReg}" 
    action="#{regBean.navigate}" value="Search" />

This is the form:

<h:form onsubmit="this.disabled=true;busyProcess();return true;">

If the submit button is pressed, a busy icon is displayed on the page until the request is processed. The problem is that the form is never submitted and the request never reaches the backend. However, if I instead output the “disconnected” call like this:

<h:form onsubmit="busyProcess();return true;">

Then everything works. Any ideas?

+3
source share
6 answers

JSF - , . ( , ) , , JSF .

, 50 . .

onsubmit="setTimeout(function(){document.getElementById('formId:buttonId').disabled=true;},50);busyProcess();"

return true; , , . , HTML , disabled, (, , ).

:

<h:form onsubmit="busyProcess(this);">

function busyProcess(form) {
    setTimeout(function() {
        for (var i = 0; i < form.elements.length; i++) {
            form.elements[i].disabled = true;
        }
    }, 50);

    // Remnant of your code here.
}

: , , "", disabled , MSIE (..), () . , .

+5

this.disabled = true [buttonref].disabled = true

+1

, , , . , , .

0

, .

, busyProcess() .

0

, , .

, AJAX , , ( , ..)

0

BalusC, . , "disabled" . Opera Firefox. , , IE.

Sean K, - , , .

!

0

Source: https://habr.com/ru/post/1745868/


All Articles