Note that there are some explanatory texts on larger screens.

plurals
  1. POusing p:fileUpload with AJAX
    text
    copied!<p>I am using PrimeFaces <strong>p:fileUpload</strong> to transfer images to the backing bean as per the manual like so:</p> <pre><code> &lt;h:outputLabel value="Select Files:" /&gt; &lt;p:fileUpload fileUploadListener="#{uploadImage.doUpload}" multiple="true" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" description="Select Images" update="@form" /&gt; </code></pre> <p>The component allows the user to select a number of files to upload in a batch, which is really convenient. However before storing them in the data base I want the user to type in more information (i.e. an image title) so the <strong>doUpload()</strong> method takes the uploaded files and saves them to a property named <strong>work</strong> which is a list of objects.</p> <p>Later in the page (inside the same <strong>h:form</strong>) I have a data table that shows the uploaded files that need to be processed.</p> <pre><code> &lt;p:dataTable value="#{uploadImage.work}" var="unit" resizableColumns="true" rendered="#{not empty uploadImage.work}"&gt; </code></pre> <p>The problem is that the data table is only redrawn once, no matter how many files get uploaded. The <strong>doUpload()</strong> method gets called each file. So when I click the <strong>Upload</strong> button on the component the <strong>p:dataTable</strong> appears, but only has one row in it no matter what. If I refresh the screen all the rows appear.</p> <p>Is there any way to re-render the <strong>p:dataTable</strong> each time <strong>doUpload()</strong> exits?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload