Yesterday I was trying to create a page where the user attach an image to an article and I wanted him to see what image he is attaching before saving the form. I was facing a huge problem which was that the image was only refreshing the first time the user uploads an image, but the second time nothing happens. I am using Primefaces 2.2.
To solve this I did the following:
Check the following source for more details
AchievmentOperationController.java
AchievmentOperationServlet.java
achievmentOperation.xhtml
To solve this I did the following:
- Stored the image in a session attribute within the fileUploadListener
- Retrieved the image inside a servlet and cleared the session attribute
- added a javascript within a primefaces outputpanel that changes the image source to the servlet path and added a date parameter to insure that the request will be done everytime this script is run
- added an update attribute to the fileupload component which updates the outputpanel created in step 3.
Check the following source for more details
AchievmentOperationController.java
AchievmentOperationServlet.java
achievmentOperation.xhtml
No comments:
Post a Comment