aspose file tools*
The moose likes JSF and the fly likes p:fileUpload update attribute not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "p:fileUpload update attribute not working" Watch "p:fileUpload update attribute not working" New topic
Author

p:fileUpload update attribute not working

Mat Anthony
Ranch Hand

Joined: May 21, 2008
Posts: 236
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.



Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16065
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Mat Anthony
Ranch Hand

Joined: May 21, 2008
Posts: 236
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

Joined: May 21, 2008
Posts: 236
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

Joined: Jun 25, 2001
Posts: 16065
    
  21

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

Joined: May 21, 2008
Posts: 236
Ok Tim,
thanks for the advise, I was stuck :confused: once again.
I will give it a go :beerchug:

Mat
 
wood burning stoves
 
subject: p:fileUpload update attribute not working