How about adding a new FacesMessage from your fileUploadListener?
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.
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).
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.