Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-3836

f:ajax disabled=false in commandButton with onclick prevents form submission

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.0-beta
    • Fix Version/s: 2.0.20, 2.1.14, 2.2.0
    • Component/s: JSR-314
    • Labels:
      None
    • Environment:
      MyFaces 2.2.0-beta, WildFly 8.0.0.Beta1, Jdk 1.7.0_25, Chrome 30.0.1599.101 m

      Description

      For <f:ajax> with disabled=true inside of a <h:commandButton> with an onclick function, MyFaces renders return=false after an unnecessary jsf.util.chain() call in the rendered <input> onclick, effectively preventing form submission. Consider the following simple commandButton

      <h:commandButton id="button1" value="AjaxTest" action="index" onclick="alert('test')">
      <f:ajax disabled="true" />
      </h:commandButton>

      This will render as follows:
      <input id="form1:button1" name="form1:button1" type="submit" value="AjaxTest" onclick="jsf.util.chain(document.getElementById('form1:button1'), event,'alert(\'test\');'); return false;">

      Clicking the button will neither trigger an ajax request, which it shouldn't, nor trigger a form submit, which it should.

      Removing the <f:ajax> tag entirely renders the following functional submit button:
      <input id="form1:button1" name="form1:button1" type="submit" value="AjaxTest" onclick="var cf = function()

      {alert('test')}

      ;var oamSF = function(){};return (cf.apply(this, [])==false)? false : oamSF.apply(this, []); ">

        Attachments

        1. MYFACES-3836.patch
          1 kB
          Ali Cheaito

          Activity

            People

            • Assignee:
              lu4242 Leonardo Uribe
              Reporter:
              acheaito Ali Cheaito
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: