问题
该代码存在以下问题:
- Ajax调用(
<a4j:commandButton .../>
)不适用于附件。 - 创建输出内容必须首先发生。
- 显示错误消息也不能使用基于Ajax的
a4j
标签。
解
- 更改
<a4j:commandButton .../>
为<h:commandButton .../>
。 - 更新源代码:
- 更改
bw.write( getDomaindocument() );
为bw.write( document );
。 - 添加
String document = getDomaindocument();
到的第一行try/catch
。
- 更改
- 将
<a4j:outputPanel.../>
(未显示)更改为<h:messages showDetail="false"/>
。
本质上,删除与相关的所有Ajax工具
commandButton。仍然可以显示错误消息并利用RichFaces UI样式。
参考资料
- 在jsf页面中使用commandButton下载文件
- http://www.preranch.com/t/483892/JSF/java/when-commandButton-commandlink
- http://seamframework.org/135584.lace



