-
1. Re: rich:fileUpload - always correct file status
michpetrov Apr 18, 2014 7:42 AM (in response to artur17)Hi,
I'm not sure I understand your problem. Does the exception occur before the listener is called? Or are you trying to let the user know something happened inside the listener?
-
2. Re: rich:fileUpload - always correct file status
artur17 Apr 18, 2014 8:22 AM (in response to michpetrov)Option 2, which I'm going to tell the user that the operation performed within the method 'listener' failed.
When I turn bug with 'try / catch', in the control the user has information that the file upload operation went fine.
I should add that I use RichFaces 3.3.1
-
3. Re: Re: rich:fileUpload - always correct file status
michpetrov Apr 18, 2014 8:33 AM (in response to artur17)I see. Your listener is not part of the file upload process. The upload ends when the file gets to the server, after that the listener is triggered.
If you want to tell the user something went wrong in your method you have to implement your own way of doing it, in the photoalbum demo we use this:
public static void addFacesMessage(String componentId, String summary, String detail) { UIComponent root = FacesContext.getCurrentInstance().getViewRoot(); UIComponent component = root.findComponent(componentId); FacesContext.getCurrentInstance().addMessage(component.getClientId(FacesContext.getCurrentInstance()), new FacesMessage(FacesMessage.SEVERITY_ERROR, summary, detail)); }
You can then use a <rich:message> or <rich:notifyMessage> that will display the error:
<r:notifyStack direction="vertical" position="topLeft" id="stack"> <r:notifyMessages for="overForm" styleClass="photoalbum-message" sticky="true" stack="stack" showDetail="true" showSummary="true" /> </r:notifyStack>
-
4. Re: Re: rich:fileUpload - always correct file status
artur17 Apr 23, 2014 5:00 AM (in response to michpetrov)Thank you for your response.
I understand that my situation is not possible to display the component 'rich: FileUpload' transferErrorLabel instead doneLabel to let you know which files have been sent.
Therefore, the answer must be in a different type of component messages. Only in my version of FF (3.3.1) there is a problem with the submit form.
When you click 'Upload' does not appear to me message. So I tried to add a separate button to send:
<a4j:commandButton id="uploadFormButton"
value="Send"
onclick="#{rich:component('fileUploadId')}.submitForm();"
oncomplete="#{rich:component('fileUploadId')}.clear();"/>
...but then I lose the animation on a component in the shipping cycle files.
Is there a possibility to use the 'Send' button on the component 'rich: FileUpload' and receive an answer in component 'h: messages'?
-
5. Re: Re: rich:fileUpload - always correct file status
michpetrov Apr 23, 2014 5:45 AM (in response to artur17)I'm not sure I understand. You put files into the fileUpload and you click "Upload". What do you want to happen next?
-
6. Re: Re: rich:fileUpload - always correct file status
artur17 Apr 23, 2014 6:32 AM (in response to michpetrov)I put files into the FileUpload and you click " Upload" .
All files are sent .
At the end I want to draw a message to 'h : messages ', but I do not get it .
As you can see this message ?
<rich:fileUpload fileUploadListener="#{$bean$.listener}"
id="fileUploadId" allowFlash="false"
<a4j:support event="onfileuploadcomplete" reRender="messages" />
</rich:fileUpload>
<h:messages id="messages" />
I would add that the message appears correctly when I use another button to review the form for approval:
<a4j:commandButton id="uploadFormButton"
value="Send"
onclick="#{rich:component('fileUploadId')}.submitForm();"
oncomplete="#{rich:component('fileUploadId')}.clear();"/>