0 Replies Latest reply on Jan 10, 2012 11:38 AM by allati

    Command button 'onclick' event not fired immediately after AJAX update

    allati

      Code sample:

       

      <h:inputText id="field" type="text" value="#{bean.field}">
          <a4j:support event="onchange" action="#{bean.enableBtn}" reRender="btn" ajaxSingle="true" />
          <a4j:support event="onkeyup" action="#{bean.enableBtn}" reRender="btn" requestDelay="1000" ajaxSingle="true" />
      </h:inputText>
      
      <a4j:commandButton id="btn" value="Submit" action="#{bean.action}" disabled="#{!bean.btnEnabled}" />
      

       

      Initially 'btn' button is disabled. Whenever user fills field with the correct data button is enabled. We use RF 3.3.3.

      The problem with this sample page is that immediately after button is enabled (i.e. ~200ms after DOM update) onclick event just doesn't fire in webkit browsers and IE. I checked it with chrome's "Event Listener Breakpoint" for the onclick event.

       

      It looks like the following happens:

      • 0 ms - user fills field with correct data and waits for the submit button to be enabled (focus still in that field)
      • 1000 ms - client side receives reply and enables button
      • 1090 ms - user clicks on the button => "field" onchange event fired => button stops to react to the onclick events
      • 1090+x ms - button starts to react to the onclick events (x is about 100ms)

       

      If I set requestDelay="200" for the onchange event - immediate click works fine, but I have a nasty feeling that after 200ms button will hit this "onclick blind spot" again.

       

      Nothing relevant found in RF's JIRA so far, but could it be a known bug? Are there any alternative ways to implement described behavior? Any additional recommendations?

       

      Thanks,

      Vadim Dmitriev.