fileUpload component will not reset after batch is done #4769
-
|
We want to limit uploads to 5 at a time and < 600 MB. After doing a batch of 5 files, nothing I do gets the component to "reset" so the user can upload another batch of five. They can select files, but to component ignores them. How do I do this? <p:fileUpload id="fileUploaderId" widgetVar="fileUploader"
fileUploadListener="#{documentFolderController.handleFileUpload}"
mode="advanced" dragDropSupport="true" multiple="true"
sizeLimit="629145600" fileLimit="5" sequential="true"
label="Select File(s)" uploadLabel="Upload" cancelLabel="Clear"
process=":docFolderForm:idCategoryType :docFolderForm:idFolderName :docFolderForm:idsummaryOfDocs :docFolderForm:idDocFolderDocDetails"
onupload="handleBatchUpload(xhr, status, args)" />
<script type="text/javascript">
<![CDATA[
function handleBatchUpload(xhr, status, args) {
// Automatically re-trigger the next batch once the first 5 are processed
if(args && args.batchRemaining === 0) {
PF('fileUploader').reset();
}
}
]]>
</script> |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
|
I moved the script to an external file and include it on the page: <script src="/resources.js/handleBatchUpload.js" ></script>
function handleBatchUpload(widget) {
if ( widget != null ) {
if ( widget.files.length === 0) {
widget.reset();
} else {
alert("count: " + widget.files.length);
}
} else {
alert("NOT widget");
}
return true;
}None of the alerts show up either. The control uploads a single file and just stops. |
Beta Was this translation helpful? Give feedback.
-
|
Which Primefaces version are you using? Maybe provide an executable example using the PrimeFaces Test project (https://github.com/primefaces/primefaces-test) so developers can debug. |
Beta Was this translation helpful? Give feedback.
-
|
I was afraid someone would ask that. 6.0 I know, I know. In progress update to 13 is in progress, but right now, I'm stuck with 6. |
Beta Was this translation helpful? Give feedback.
-
|
Not familiar with upload in primefaces 6.0. My advise is to look at old user guide or showcase. |
Beta Was this translation helpful? Give feedback.
-
|
This seems odd to me: onupload is not in the documentation of 6.0 I would try (suggestion), define: onstart="handleBatchUpload([{name:'filesCount', value: PF('fileUploader').files.length}]);" Also define remoteCommand for oncomplete, to see if all files are completed, if so PrimeFaces.current().ajax().update the component. |
Beta Was this translation helpful? Give feedback.
-
|
i would bet a ton of money this bug is fixed in a much later version than 6.0 😄 |
Beta Was this translation helpful? Give feedback.
i would bet a ton of money this bug is fixed in a much later version than 6.0 😄