1 Reply Latest reply on Oct 9, 2012 1:29 PM by Ernesto Hernandez

    Disabling a h:commandButton in the onclick event, it does avoid the submit!

    Ernesto Hernandez Newbie

      Hi guys!

       

      I have an issue right now with a h:commandButton. I'm using JSF 2.0 and Richfaces 4.2.2.

      I'm getting an undesirable behavior of that button once I do a click over it. I have a JavaScript call in the onclick event, in order to disable the button.

      This is what I have inside that event: onclick="this.disabled=true;". This works as I expect it should work, I mean, the button is disabled once I click it.

      But the problem comes at the moment I click the button because the submit call does not work, instead of that, in IExplore 9 and Firefox 15 the page is reloaded again.

      I have a break point in the server side, which is never reached when I click the button. I don't know why this is happening. I suppose the Submit call should achieve without any problem. The button should be disabled but at the same time doing the submit call.

       

      Thi is the code for that button:

       

      <h:commandButton value="Continuar" rendered="#{entriesBean.variables.idScreen eq 'S014'}"

           actionListener="#{entriesBean.finalizarRevision}" onclick="this.disabled=true;"

           disabled="#{entriesBean.allowButtonDisabled and not !facesContext.validationFailed}">

           <f:setPropertyActionListener value="entriesTab" target="#{inquiry.activeTab}" />

      </h:commandButton>

       

       

      Do you guys know or have any idea about this?

       

      Thanks in advance.