Srinivas
Srinivas

Reputation: 1

How To disable a <h:commandButton> in jsf while form gets loading?

I am developing a web form using jsf. In that i need to disable the while the form gets loading,then again it wil enable after completing the form loading

Upvotes: 0

Views: 5024

Answers (2)

Bozho
Bozho

Reputation: 597106

That can be done only on the client side, with javascript:

  • disable it (set "enabled" to false) in a javascript snippet right after the button. Or in fact disabled it at the very start by setting disabled="true"
  • onload (or at the end of the body) enable it.

Upvotes: 1

BalusC
BalusC

Reputation: 1108742

Put a <script> right after the button which disables it.

<h:form id="myform">
    <h:commandButton id="mybutton" />
    <script>document.getElementById('myform:mybutton').disabled = true;</script>

On window.onload, enable it again. It doesn't matter where this script is placed.

<script>window.onload = function() { document.getElementById('myform:mybutton').disabled = false; }</script>

Upvotes: 3

Related Questions