0

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>
ayengin
  • 1,606
  • 1
  • 22
  • 47

2 Answers2

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#

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().

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I am trying to find file on server connecting remote machines and file size change a lot how can i set a suitable timeout. – ayengin Jun 09 '11 at 18:19
  • The speed of the *Save As* popup does not depend on the file size. It depends on the speed the HTTP response headers arrives. I'd say, one or two seconds ought to be reasonable. – BalusC Jun 09 '11 at 18:20
  • I know you are answering lots of question and you are an expert programmer but i am not :).So I am allready showing model panel onclick event.How can I hide it. – ayengin Jun 09 '11 at 19:51