Primefaces.addSubmitParam issue

UI Components for JSF
Post Reply
billreh
Posts: 2
Joined: 11 Apr 2010, 07:29

19 Oct 2011, 04:34

Hi,

I just noticed an issue when I was making multiple ajax requests when using Primefaces.addSubmitParam in my javascript. When multiple ajax requests are done without refreshing the page (i.e not ajax, but a full submit), new submit params with the same key do not work (you get the old one).

I've gotten around this by overriding addSubmitParam in my javascript like so:

Code: Select all

PrimeFaces.addSubmitParam  = function(parent, name, value) {
    $(this.escapeClientId(parent)).append("<input id=\"" + "submitParam_" +  name + "\" + type=\"hidden\" name=\"" + name + "\" value=\"" + value + "\"/>");

    var child = $("#submitParam_" + name);
    child.val(value);

    return this;
};
This is just a small change from the original:

Code: Select all

addSubmitParam : function(parent, name, value) {
        $(this.escapeClientId(parent)).append("<input type=\"hidden\" name=\"" + name + "\" value=\"" + value + "\"/>");
	
        return this;
    }
Don't know if anyone else has run into the same thing, but figured I'd throw it out there in case anybody found it useful. I don't think it's relavent, but just in case, I'm running the latest primefaces snapshot with mojarra-2.1.2 on glassfish 3.1.1, using Google Chrome as a browser.

Cheers,

Bill

holek
Posts: 31
Joined: 18 Oct 2011, 16:23

21 Oct 2011, 00:03

Hi,

I have similar problem using p:fileDownload in p:datatable:

Code: Select all

<p:commandLink ajax="false" value="download">
    <p:fileDownload value="#{bean.file(row)}" />
</p:commandLink>
when you click first time, file is downloaded without any problems,
but when you click on next file ( other row in datatable )
all files in one stream are downloaded ( all files downloaded earlier + clicked file )

with something similar to your code it works
js:

Code: Select all

function clearSubmit() {
    $('input[id^="submitParam_"]').remove();
}

PrimeFaces.addSubmitParam = function(parent, name, value) {
    $(this.escapeClientId(parent)).append("<input id=\"" + "submitParam_" + name + "\" type=\"hidden\" name=\"" + name + "\" value=\"" + value + "\"/>");
    return this;
};
xhtml:

Code: Select all

<p:commandLink ajax="false" value="download" onclick="clearSubmit()'>
    <p:fileDownload value="#{bean.file(row)}" />
</p:commandLink>
thanks :)

using PrimeFaces-3.0.M4-SNAPSHOT, Glassfish 3.1.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 16 guests