You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Michael Heinen <mh...@recommind.com> on 2006/07/06 09:37:25 UTC
Filedownload and progressbar
Hi all,
One of my backingBeans contains a method that returns a file for
download.
This is working fine and the standard Open/Save/Cancel box pops up. No
problem.
In addition I display always a "work on progress message" with a
javascript call when my form is submitted (onSubmit).
The problem is now that I don't know how to disable this message again
when the file is ready for download.
There is no event on which I can react in the browser. The original page
is not reloaded (and should not be reloaded).
Can I use a second jsp which calls the showOriginalDocument action and
does a javascript call in the parent window (or openener)?
Does anybody have an idea?
JSP:
<h:commandLink action="#{MyBean.showOriginalDocument}" immediate="true">
<t:graphicImage url="/images/out.jpg" />
</h:commandLink>
BackingBean:
public void showOriginalDocument() {
..
NativeDocument nativeDocument =
this.delegate.getOriginalDocument(this.document.getDocumentId());
HttpServletResponse response =
(HttpServletResponse)facesContext.getExternalContext().getResponse();
response.setContentType(nativeDocument.getMimeType());
response.setHeader("Content-Disposition","attachment;filename=\""+
this.document.getAttribute("docnumber")+nativeDocument.getSuffix() +
"\"");
response.setContentLength(nativeDocument.getDocument().length);
OutputStream responseStream =
((HttpServletResponse)facesContext.getExternalContext().getResponse()).g
etOutputStream();
responseStream.write(nativeDocument.getDocument());
response.flushBuffer();
facesContext.responseComplete();
Michael
Re: Filedownload and progressbar
Posted by Dave Brondsema <da...@brondsema.net>.
http://today.java.net/pub/a/today/2006/02/09/file-uploads-with-ajax-and-jsf.html
might help.
Michael Heinen wrote:
> Hi all,
>
>
>
> One of my backingBeans contains a method that returns a file for download.
>
> This is working fine and the standard Open/Save/Cancel box pops up. No
> problem.
>
>
>
> In addition I display always a "work on progress message" with a
> javascript call when my form is submitted (onSubmit).
>
> The problem is now that I don't know how to disable this message again
> when the file is ready for download.
>
> There is no event on which I can react in the browser. The original page
> is not reloaded (and should not be reloaded).
>
>
>
> Can I use a second jsp which calls the showOriginalDocument action and
> does a javascript call in the parent window (or openener)?
>
> Does anybody have an idea?
>
>
>
> JSP:
>
> <h:commandLink action="#{MyBean.showOriginalDocument}" immediate="true">
>
> <t:graphicImage url="/images/out.jpg" />
>
> </h:commandLink>
>
>
>
>
>
> BackingBean:
>
> public void showOriginalDocument() {
>
> ..
>
> NativeDocument nativeDocument =
> this.delegate.getOriginalDocument(this.document.getDocumentId());
>
> HttpServletResponse response =
> (HttpServletResponse)facesContext.getExternalContext().getResponse();
>
> response.setContentType(nativeDocument.getMimeType());
>
>
> response.setHeader("Content-Disposition","attachment;filename=\""+
> this.document.getAttribute("docnumber")+nativeDocument.getSuffix() + "\"");
>
> response.setContentLength(nativeDocument.getDocument().length);
>
> OutputStream responseStream =
> ((HttpServletResponse)facesContext.getExternalContext().getResponse()).getOutputStream();
>
> responseStream.write(nativeDocument.getDocument());
>
> response.flushBuffer();
>
> facesContext.responseComplete();
>
>
>
>
>
> Michael
>
--
Dave Brondsema
Software Developer
Cornerstone University