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

Serious Bug! ajax cant work using multiple forms.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 2.0.0-beta-3
    • 2.0.0
    • JSR-314
    • tomcat 6.0.20, java 1.6 (mac osx)

    Description

      I am using multiple forms. the second form can submit correctly first time, but when you submit again, the ajax cant work.
      you can try following code, first time the form f1 can reRend out1, but then form f1 cant submit any more.

      test.jspx:

      <h:head>
      </h:head>
      <h:body>
      <h:outputScript name="jsf.js" library="javax.faces" target="head"/>

      <h:form id="f0">
      </h:form>

      <h:form id="f1">
      <h:inputText value="#

      {TestBean.value}"/>
      <h:outputText id="out1" value="#{TestBean.value}

      "/>
      <h:commandButton value="click me" onclick="jsf.ajax.request(this,event,

      {execute:'@form', render:'@form'}

      );return false;"></h:commandButton>
      </h:form>
      </h:body>

      The reason i find is that:
      during the first time submit and ajax rendering, the form will lose <input type="hidden" id="javax.faces.ViewState"/> childnode. Then the following submit will not work.
      the code in jsf.js causes this problem:
      jsf.js:
      myfaces._impl.xhrCore._AjaxResponse.prototype.processUpdate = function (request, context, node) {
      if (node.getAttribute("id") == "javax.faces.ViewState") {
      sourceForm = document.forms.length > 0 ? document.forms[0] : null;
      ....
      }

      " sourceForm = document.forms.length > 0 ? document.forms[0] : null; " is wrong!
      when there is multiple forms, it will always find the first one.

      Please change this, thx.

      Attachments

        Activity

          People

            Unassigned Unassigned
            puddlor Mark Li
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 3h
                3h
                Remaining:
                Remaining Estimate - 3h
                3h
                Logged:
                Time Spent - Not Specified
                Not Specified