h:command button oncomplete action

流过昼夜 提交于 2019-12-12 06:05:59

问题


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>

回答1:


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.

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




回答2:


You can use de rich:componentControl or the JS API show function (#{rich:component('mp')}.show).

http://livedemo.exadel.com/richfaces-demo/richfaces/modalPanel.jsf?s=blueSky#



来源:https://stackoverflow.com/questions/6288803/hcommand-button-oncomplete-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!