h:命令按钮完成动作 [英] h:command button oncomplete action

查看:66
本文介绍了h:命令按钮完成动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我使用 a4j:commandLink 从服务器下载文件时,如果我使用 h:commandLink ,则文件下载失败(将文件写入浏览器屏幕)是可以的。想要在下载文件时显示丰富的模式面板,但标准组件没有完成操作,因此下载文件后我无法隐藏模式面板。如何解决此问题,我使用的是面孔3.3

When downloading file from server if i use a4j:commandLink file download fail(mean file written to browser screen) if i use h:commandLink it is okay.I want to show a rich modal panel when file downloading but standard components not have a on complete action so i cant hide modal panel after file downloaded .How can i workaround this issue,I am using rich faces 3.3

  <h:commandLink value="Download"
   action="#{logSearcher.downloadFile}" 
  onclick="Richfaces.showModalPanel('ajaxLoadingModalBox',{width:450, top:200})"
                                   immediate="true" >
                          <f:setPropertyActionListener value="#{log}"
                            target="#logSearcher.selectedLogLine}"   
                                    />                          
  </h:commandLink>


推荐答案

< a4j: commandLink> 默认情况下发送异步(ajax)请求。您不能使用异步请求下载文件。 JavaScript根本不提供将 XMLHttpRequest 响应转换为另存为对话框的功能。您需要使用正常的同步请求下载文件。 < h:commandLink> 做到这一点。

The <a4j:commandLink> sends by default an asynchronous (ajax) request. You cannot download files using asynchronous requests. JavaScript simply does not offer facilities to turn a XMLHttpRequest response into a Save As dialog. You need to download files using a normal synchronous request. The <h:commandLink> does that.

您最好的选择是使用< h:commandLink> 的> onclick 属性以关闭模式面板。如有必要,请使用 setTimeout()

Your best bet is to use the onclick attribute of <h:commandLink> to close the modal panel. If necessary with a setTimeout().

这篇关于h:命令按钮完成动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆