HTTP response header content disposition for attachments

后端 未结 5 1247
醉酒成梦
醉酒成梦 2020-12-24 14:36

Background

Write an XML document to a browser\'s response stream and cause the browser to display a \"Save As\" dialog.

Problem

Consider the foll

5条回答
  •  余生分开走
    2020-12-24 15:09

    Problems

    The code has the following issues:

    • An Ajax call () does not work with attachments.
    • Creating the output content must happen first.
    • Displaying the error messages also cannot use Ajax-based a4j tags.

    Solution

    1. Change to .
    2. Update the source code:
      1. Change bw.write( getDomainDocument() ); to bw.write( document );.
      2. Add String document = getDomainDocument(); to the first line of the try/catch.
    3. Change the (not shown) to .

    Essentially, remove all the Ajax facilities related to the commandButton. It is still possible to display error messages and leverage the RichFaces UI style.

    References

    • Using a commandButton in a jsf Page to download a file
    • http://www.coderanch.com/t/483892/JSF/java/when-commandButton-commandLink
    • http://seamframework.org/135584.lace

提交回复
热议问题