MyFaces Core
  1. MyFaces Core
  2. MYFACES-3045

jsf.js jsf.ajax.request doesn't resolve calling URL correctly -- ajax use in portlets broken

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.5-SNAPSHOT
    • Fix Version/s: 2.0.5
    • Component/s: JSR-314
    • Labels:
      None

      Description

      Javadoc for jsf.ajax.request says you determine the calling URL by:
      Determine the posting URL as follows: If the hidden field javax.faces.encodedURL is present in the submitting form, use its value as the posting URL. Otherwise, use the action property of the form element as the URL.

      Looks like the MyFaces impl skips loking for/using the javax.faces.encodedURL and only uses the form action. This means ajax is broken in portlets (when using MyFaces). I.e. the javax.faces.encodedURL in the portlet case is different than the action URL and the one that needs to be used.

      1. MYFACES-3045-1.patch
        1.0 kB
        Leonardo Uribe

        Activity

        Hide
        Werner Punz added a comment -

        fixed and applied thanks for providing the patch

        Show
        Werner Punz added a comment - fixed and applied thanks for providing the patch
        Hide
        Werner Punz added a comment - - edited

        looks good to me feel free to apply it since I am currently bound by my newborn.

        Show
        Werner Punz added a comment - - edited looks good to me feel free to apply it since I am currently bound by my newborn.
        Hide
        Leonardo Uribe added a comment -

        Ok, I have attached the patch. In theory it looks good, but it could be good if Werner take a look to this one.

        If no objections I'll commit this code soon.

        Show
        Leonardo Uribe added a comment - Ok, I have attached the patch. In theory it looks good, but it could be good if Werner take a look to this one. If no objections I'll commit this code soon.
        Hide
        Michael Freedman added a comment -

        A potential patch (this works for me): replace the line in _AjaxRequest._startXHR:
        this._xhr.open(this._ajaxType, this._sourceForm.action+
        ((this._ajaxType == "GET")? "?"+this._requestParameters.makeFinal():"")
        , true);

        with the following lines:

        var targetURL;
        if (typeof this._sourceForm.elements["javax.faces.encodedURL"] == 'undefined')

        { targetURL = this._sourceForm.action; }

        else

        { targetURL = this._sourceForm.elements["javax.faces.encodedURL"].value; }

        this._xhr.open(this._ajaxType, targetURL +
        ((this._ajaxType == "GET")? "?"+this._requestParameters.makeFinal():"")
        , true);

        Sorry no patch file as the one that the Diff program used to generate the patch seems to want to replace everything...And anyway I am not authorized to provide includable patches.

        Show
        Michael Freedman added a comment - A potential patch (this works for me): replace the line in _AjaxRequest._startXHR: this._xhr.open(this._ajaxType, this._sourceForm.action+ ((this._ajaxType == "GET")? "?"+this._requestParameters.makeFinal():"") , true); with the following lines: var targetURL; if (typeof this._sourceForm.elements ["javax.faces.encodedURL"] == 'undefined') { targetURL = this._sourceForm.action; } else { targetURL = this._sourceForm.elements["javax.faces.encodedURL"].value; } this._xhr.open(this._ajaxType, targetURL + ((this._ajaxType == "GET")? "?"+this._requestParameters.makeFinal():"") , true); Sorry no patch file as the one that the Diff program used to generate the patch seems to want to replace everything...And anyway I am not authorized to provide includable patches.

          People

          • Assignee:
            Unassigned
            Reporter:
            Michael Freedman
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development