I came up with this workaround that does not reset the file restriction counter itself, but instead resets the fileUpload component to reset the counter. Thus, the parameter fileLimitlimits the number of files per download, not per page.
First, let's define a function reset()in the PrimeFaces FileUpload component:
PrimeFaces.widget.FileUpload.prototype.reset = function() {
this.clearMessages();
return this.init(this.cfg);
}
This method resets the component by calling init()with the current configuration.
Then you just need to call this method in FileUploadEvent as follows:
public void uploadFile(FileUploadEvent event) {
RequestContext.getCurrentInstance().execute("PF('fileUploadWidgetVar').reset();");
}
And now every time you process the downloaded files, the counter is reset, because the component is also reset.
source
share