You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Kołoszko Paweł <pa...@atena.pl> on 2005/06/29 18:08:46 UTC

How to open page and download file in one turn?

I have page B opened from page A. I insert some data on page B and submit
the form. Then action is performed which generates Word document. After that
it returns to page A. The problem is: how to open page A and then download
automatically generated document? I know how to open page A, I know how to
download generated document, but I do not know how to open page A AND
download document after pressing submit button on page B. I tried many
things and none of them works. Do you have any ideas?
 
Pawel
 
 

Re: How to open page and download file in one turn?

Posted by Csík Norbert <no...@gmail.com>.
Hi!

I think you should send 2 requests to the server. On the first request
you generate the response page, and the response file, and send the
generated page. On the response page You should put some trick (eg. a
non-visible iframe) to post the second request to download the
generated file too.

On 6/29/05, Kołoszko Paweł <pa...@atena.pl> wrote:
>  
> I have page B opened from page A. I insert some data on page B and submit
> the form. Then action is performed which generates Word document. After that
> it returns to page A. The problem is: how to open page A and then download
> automatically generated document? I know how to open page A, I know how to
> download generated document, but I do not know how to open page A AND
> download document after pressing submit button on page B. I tried many
> things and none of them works. Do you have any ideas? 
>   
> Pawel 
>   
>   


-- 
  Norbert Csík

Re: How to open page and download file in one turn?

Posted by Slawek <ss...@o2.pl>.
page A may (or may not - explain later) have onload attrib=sommeJSfunction.
that fucntion can open new window: window.open - opened in popup page can 
return to u special header with doc to download.

when page a should have or not onload attrib:

<h:outputText value="<body>" escape="false" 
rendered="#{!bean.shouldMakePopup}">
<h:outputText value="<body onload='openPopUp()'>" escape="false" 
rendered="#{bean.shouldMakePopup}">

boolean bean.sholdMakePopup can be set when submiting form from B page


i dont know if i understand twój;) problem Pawel - maybe u mean that page 
B is popup?


cheers

Slawek


> I have page B opened from page A. I insert some data on page B and submit
> the form. Then action is performed which generates Word document. After 
> that
> it returns to page A. The problem is: how to open page A and then 
> download
> automatically generated document? I know how to open page A, I know how 
> to
> download generated document, but I do not know how to open page A AND
> download document after pressing submit button on page B. I tried many
> things and none of them works. Do you have any ideas?
>
> Pawel
>
>



Re: How to open page and download file in one turn?

Posted by Mike Kienenberger <mk...@gmail.com>.
On 6/29/05, Kołoszko Paweł <pa...@atena.pl> wrote:
> I have page B opened from page A. I insert some data on page B and submit
> the form. Then action is performed which generates Word document. After that
> it returns to page A. The problem is: how to open page A and then download
> automatically generated document? I know how to open page A, I know how to
> download generated document, but I do not know how to open page A AND
> download document after pressing submit button on page B. I tried many
> things and none of them works. Do you have any ideas? 

I could be wrong, but aren't you only allowed one response for an html
request?   So you can either return a new page, or you can return a
document to download (really, just another page), but you can't return
both at the same time.

Maybe you could get around it with javascript and the target="_blank"
link attribute, though.