• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Updating page when uploading files  RSS feed

Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers,

I have a question about how to update a page when files are uploaded. I got the basic code using PrimeFaces and the <p:fileUpload> tag to work straight away from the example given at:


after putting the PrimeFaces jar file in my WEB-INF\lib folder in Eclipse, together with two other jars necessary for uploading, and adding the neccesary code to the web.xml file.

What I want to do is display on the screen a list of files that have been uploaded, together with a message for each file indicating whether it has been successfuly uploaded or not, but I do not know how to get the screen to automatically refreshed on each file upload, and have added a button to do this manually, which is not very satisfactory.

The xhtml code is as follows:

The idea is that you click the choose button generated by PrimeFaces, then select a file to upload, then upload it. This part works correctly, but what I want is the list displayed to be updated, first with the first file uploaded, followed by the second, and so on, and in each case a message is displayed to the right of that file. However, at the moment I have to click the Refresh button which fires an action event that does this.

This is based on some original code I wrote a while ago that uses other software for uploading files, and the display was generated entirely by JavaScript, and I want to keep most of the basic appearance similar.

The java code is as follows:

On specifying the number of files you want to upload then clicking the "Update" button, a table is displayed with the first columns as "File 1", "File 2", "File 3", etc., to the right of that is a blank column, and to the right the characters "XXXX" are currently displayed as a place holder. On each file upload the file name is placed in the middle column, and "XXXX" is replaced by an appropriate message.

The code needs to be tidied up and some changes have to be made anyway, but in the first instance I would like to know how to update this table directly on each file upload, without having to fire an action event using the "Refresh" button, which I want to remove. The ArrayList holding boolean values will eventually be used to keep track of those files that have been successfuly uploaded, for which the user need take no further action.

I would be most grateful for some advice on this.

Christopher Sharp>
Christopher Sharp
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shortly after posting this I found a solution. You give a name to the update attribute in the <p:fileUpload> tag which references the id of the <p:dataTable> tag. In my case I used update="fileTable", then id="fileTable" in the dataTable tag, and it works.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!