Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

p:fileUpload update attribute not working

 
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I'm trying to change the default value within h:outputLabel every time I upload an image using p:fileUpload.
The default value set to 'INIT' is always displayed within h:outputLabel, even though the value is changed
within the handleFileUpload method to 'UPDATED'. The method getTest() even gets called.
How can I get the h:outputLabel value to change from 'INIT' to 'UPDATED' when I upload an image.



 
Saloon Keeper
Posts: 25459
180
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see anything obviously wrong, although file uploading is stuff I don't remember in between uses.

But what is the purpose of this statement?


Incidentally, in JSF, all the Controllers are pre-written parts of JSF itself. Backing beans are always Models, and action methods are external to the MVC paradigm, not controller methods. By definition, a Controller is strictly charged with keeping Model and View in sync.
 
Mat Anthony
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim,
I'm trying to use <p:fileUpload and ><p:lightBox together. I would like to be able to upload an image into a byte[] then show it in lightBox.
The lightbox function will allow the user to view the image as a thumb nail or expanded. At this stage I dont want the image to be stored in the database
until the user has filled in the rest of the form. I noticed that even though I uploaded the image into a byte[] it never updated the screen.
I replaced the ><p:lightBox with ><h:outputLabel and this samething was happening. The prev code that I sent should have contained the ><h:outputLabel
within ><p:panelGrid as below. I read somewhere that this allowed the outputLabel compnent still to be found in the html tree via it's id?
Tim ignore the FacesContext.getCurrentInstance().addMessage(null, null); as I was just trying to keep the example small.


 
Mat Anthony
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim,
do you have any ideas of how I can get p:lightBox and p:fileUpload to work together without storing the image in a database or file.

Mat
 
Tim Holloway
Saloon Keeper
Posts: 25459
180
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think you'll have any success there. The upload and display are going to be in 2 separate HTTP requests, and unless you intend to keep the image in a session object, you'll need a persistent place to store it.

In J2EE, the server co-opts the java.io.File tempfile functions to permit the creation of temporary files in a place that's convenient to the J2EE server. You don't need to know its actual filesystem location as long as you use the tempfile API functions.

So what I normally do is stream the uploaded data into a temporary file, store its location in the session, provide a mechanism where a request for that image is then output and delete the file when no longer needed.

I haven't worked with PrimeFaces recently, but I seem to recall that RichFaces file upload included a means of displaying post-upload thumbnails with relatively minor pain, so you might want to double-check the Primefaces docs.
 
Mat Anthony
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok Tim,
thanks for the advise, I was stuck :confused: once again.
I will give it a go :beerchug:

Mat
 
Fire me boy! Cool, soothing, shameless self promotion:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic