Re: Custom Ajax arguments

From: Anahide Tchertchian <>
Date: Mon, 17 Nov 2014 15:01:56 +0100


Michal, many thanks for handling

I'm answering here because i'd like to understand what's the standard
target plan when it comes to handle ajax requests within multipart forms.

For now we're running on top of Mojarra 2.2.6 and RichFaces 4.5.0 Alpha3
and we're using an ugly patch (see below) to be able to handle properly
these behaviours.
We do have multipart forms that need to perform additional ajax requests,
and we ran into issues at render (target="JSFFrameId" being added to the
form, or some RichFaces tags like a4j:jsFunction not working as expected).

I see that has been fixed
for 2.2.9, does it improve things regarding this behaviour, by any chance?
Are there any other fixes or improvements linked to this issue for 2.2.9?


Here is our current patch:

// Script patching the JSF library to let richfaces parameters go through
// when performing an ajax request in a multipart form, see NXP-14230.
// The idea is to trick the js call into thinking form is not multipart only
// while building the transport, to avoid using a frame transport.
if (window.jsf) {
  var jsfAjaxRequest = jsf.ajax.request;
  var jsfAjaxResponse = jsf.ajax.response;
  var getForm = function getForm(element) {
    if (element) {
      var form = jQuery(element).parents("form");
      if (form.length === 0) {
        form = jQuery(document.forms[0]);
      return form;
    return null;
  jsf.ajax.request = function request(source, event, options) {
    var form = getForm(source);
    var cheating = false;
    if (form && form.attr("enctype") == "multipart/form-data") {
      form.attr("enctype", "");
      cheating = true;
    var res = jsfAjaxRequest(source, event, options);
    if (cheating) {
      form.attr("enctype", "multipart/form-data");
    return res;

On 6 November 2014 17:53, Michal Petrov <> wrote:

> Hi,
> I'm wondering what's the status quo regarding custom arguments in a
> request to server.
> This concerns jsf.js: In forms with enctype="multipart/form-data" when
> using FrameTransport only the standard arguments ("javax.faces.source",
> "javax.faces.partial.ajax", etc.) are let through (which was introduced as
> a fix for #2978).
> This breaks RichFaces functionality as we rely on custom arguments to be
> passed to the server as well. Are custom arguments supported, in which case
> is this behavior a bug? Or is this working as intended?
> Thanks,
> Michal Petrov