Question

I am using RichFaces 3.3 and Seam 2 to develop a web application.

I have a page with the following:

<h:form>
<s:div id="myPanel">
  <h:messages/>
  <rich:fileUpload fileUploadListener="#{service.uploadEvent}" maxFilesQuantity="1">
    <a:support event="onuploadcomplete" reRender="myPanel"/>
  </rich:fileUpload>
</s:div>
</h:form>

In the service.uploadEvent method, I receive the file and add a FacesMessage to let the user know the file uploaded succesfully.

What actually happens is this:

  1. The browser requests the page
    • The server starts temporary conversation #1
    • The server renders the page
    • The server sends the completed page and kills conversation #1
  2. The client launches an AJAX fileUpload call
    • The server starts temporary conversation #2
    • The server calls service.fileUpload(). This method adds a FacesMessage to the Conversation-scoped FacesMessages seam component.
    • The server returns the response for the AJAX request and kills conversation #2, including all queued FacesMessages.
  3. The 'onuploadcomplete' event is received, the client requests a reRender of 'myPanel'
    • The server starts temporary conversation #3
    • The server renders the page, creates a new empty FacesMessages for conversation #3
    • The server returns the response for the AJAX request (which contains an empty <h:messages/>) and kills conversation #3

I can solve this in a number of ways:

  1. By creating a new FacesMessages component which is PAGE-scoped.
  2. By marking the conversation as long-running in service.fileUpload() and ending it upon doing fileUploadComplete().

The proper way would be to reRender the page in the same conversation as service.fileUpload(). Is this possible?

Was it helpful?

Solution

This can only be solved by using a custom StatusMessages component and scoping it to a context which will still be available on Rerender (e.g. PAGE or longrunning CONVERSATION).

OTHER TIPS

Have you tried replacing <h:messages /> with <rich:messages />? It works well when AJAX actions create new FacesMessages. See http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/rich_messages.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top