-
1. Re: Getting feedback from rich:fileUpload listener for each file from listener
bleathem Aug 22, 2013 4:10 PM (in response to vrockai)How about adding a new FacesMessage from your fileUploadListener?
-
2. Re: Getting feedback from rich:fileUpload listener for each file from listener
pmensik Aug 23, 2013 2:59 AM (in response to vrockai)Or, in case that you are using CDI in you application, you could fire a CDI event in your listener and then make some appropriate reaction based on your event in the observer.
-
3. Re: Re: Getting feedback from rich:fileUpload listener for each file from listener
vrockai Aug 26, 2013 11:37 AM (in response to bleathem)Maybe I just don't know how to use that correctly. If the info below is not the way you had in your mind, please give me more hints.
I don't know how to resolve this in an elegant way using message. The way I know about using FacesMessage is something like this:
final FacesContext context = FacesContext.getCurrentInstance(); final FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, filename, null); context.addMessage(component.getClientId(), facesMsg);
But this is restricted to request, so at one time, I've got information only about single file. What comes to my mind is storing the list of invalid files in a bean (when listener gets an error, it'll add the currently processed filename to the list). The last part of listener would consists of adding the file names from that list to the context messages. But parsing messages with JS and updating the file list in uploader seems a bit overkill (+ troubles with clearing the file uploader list).
-
4. Re: Getting feedback from rich:fileUpload listener for each file from listener
bleathem Aug 27, 2013 5:44 PM (in response to vrockai)Viliam Rockai wrote:
- final FacesContext context = FacesContext.getCurrentInstance();
- final FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, filename, null);
- context.addMessage(component.getClientId(), facesMsg);
That's what I was thinking. Am I understanding you correctly in that you don't like this solution because it gives feedback one file at a time, and you would rather display the feedback altogether after some processing has occurred? This seems contrary to your original request for "feedback from the rich:fileUpload component for each file separately". There is likely something I am missing.
As for a workaournd to the immediate problem you described, You could store the clientId and the message text in a bean, and create the FacesMessages when you are ready for them to be displayed.
If this is not sufficient, please clearly described your use case, and we'll see if we can uncover a feature request.