1

I have a jsf form with h:commandButton as submit button:

<h:form>
     <h:commandButton id="import_opener" binding="#{submit}" disabled="true" action="#{bean.save}" value="submit"/>
</h:form>

and I try to set "disabled" attribute to true (to enable the button) by JQuery:

$("[id='#{submit.clientId}']").prop("disabled", false);

and everything works fine. But when I submit commandButton the action #{bean.save} doesn't fire, just reloads the form page. If I do not operate on the h:commandButton by JQuery the action is fire.

Please, help me to run #{bean.save} after JQuery has changed the disable attribute of h:commandButton.

1 Answer 1

1

This is because JSF has some built-in security features. The incoming request is checked if it is "possible" or not. The incoming request tells JSF that a button, which actually was disabled has been pressed. So the request will be handled as invalid and kind of refused. This is good because the browser can be manipulated in many ways.

The solution is to not set disabled="true", but let it enabled on the JSF side and disable it via jQuery, instead of the other way around.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.