Having struggled with this particular combination -- FileUpload and MediaOutput -- in the earlier versions of Richfaces 3.x, it was nice to see that Richfaces 4 has addressed some of the concerns, especially around these two areas:

 

1. Better parameter names and successful uploads of some files, and various minor improvements such as: on a multiple file upload, allows some files through even the total number of files exceeds the upload limit.

 

       <rich:fileUpload fileUploadListener="#{fileUploadBean.listener}" 
                  id="upload" acceptedTypes="txt,png,jpg">
             <a4j:ajax event="uploadcomplete" execute="@none" render="info" />
       </rich:fileUpload>

 

 

2. Content-Disposition header is now present and, in addition to inline presentation, also allows presentation of a download as a link to a Richfaces resource.  In this example, a text file is available for download as a link or for viewing in the browser, with the content having been generated through the 'generate' method on the backing bean.  This tag is embedded in a loop, and the 'row' is being passed to the generate method.

 

       <a4j:mediaOutput element="a" mimeType="text/plain"
              createContent="#{fileUploadBean.generate}" value="#{row}"
              charset="UTF-8" fileName="#{file.outputPageName}" 
              style="width:100px; height:100px;" cacheable="false">
              <f:param value="#{fileUploadBean.timeStamp}" name="time" />
              Download
          </a4j:mediaOutput>

 

However, as far as I have been able to find out, a content disposition of attachment is still not configurable.  This is the case when the user gets prompted for a download even if the browser has the capability to show the content inline, either intrinsically or though a plugin/extension.