Who can explain the following behaviour? When disabling a command button in JavaScript, the action method is never executed.
<h:form>
<h:commandButton value="test" action="#{bean.test}" onclick="disabled=true" />
</h:form>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When a HTML form element is disabled, then its
name=valuepair won’t be sent as HTTP request parameter and hence JSF will never find it in the request parameter map. For command buttons this in turn means that the action is never invoked.You need to disable the button shortly after the form has been submitted. The proposed suggestions to use
disabledattribute make no sense as it’s too late. It’s not set during submitting the form, but it’s only set when the response returns.To achieve your particular functional requirement in this particular case, you could use JS to timeout the disablement.
Much better is however to use
<f:ajax onevent>See also: