Download works perfectly inside the dialog. I thought a workaround would be to simply navigate the dialog to a confirmation page which the user could then dismiss, however, it seems that the dialog refuses to navigate after the download. (Without any download action, the navigation works perfectly)
I have also tried using the tr:fileDownloadListener, but the effect is the same. Any other points of advice would be appreciated. Kind Regards, Oscar On Nov 9, 2007 4:17 PM, Matthias Wessendorf <[EMAIL PROTECTED]> wrote: > sounds like that this happens. > download inside the dialog possible ? > > On Nov 9, 2007 2:30 PM, Oscar Reitsma <[EMAIL PROTECTED]> wrote: > > Hi Matthias, > > > > Thanks for your response. > > > > That is one of the puzzling things. neither the commandLink launching > the > > dialog, nor the commandButton that causes the returnFromDialog method to > be > > called uses partial submit. > > > > As for the exception resulting from the 2nd process outlined in my > original > > mail, I found this link: http://jira.codehaus.org/browse/JETTY-231 > > If I understand the message from Greg Wilkins on that page correctly, > then > > according to the JSF spec binary file download cannot take place in the > same > > response as the returnFromDialog instruction, if the latter causes a > call to > > getWriter on the response Stream. > > > > Am I interpretting that correctly? > > > > Once again, thanks for the support, > > > > Kind Regards, > > Oscar Reitsma > > > > > > > > On Nov 9, 2007 2:46 PM, Matthias Wessendorf < [EMAIL PROTECTED]> wrote: > > > I think partialSubmit must be false on the parent component (the one > > > that contains the listener) > > > > > > -M > > > > > > > > > > > > > > > On Nov 9, 2007 1:15 PM, Oscar Reitsma <[EMAIL PROTECTED]> wrote: > > > > Good Day, > > > > > > > > I am having an issue downloading a file depending on parameters > inputted > > on > > > > a dialog. Perhaps someone could point me in the right direction > > > > > > > > Basically required functionality is as follows: > > > > - A user clicks on a link to generate a report. > > > > - A dialog pops up where the user can input parameters for the > report. > > > > - The user clicks the OK button > > > > - The report is generated, and sent to the user as a file download. > > > > > > > > Versions: > > > > MyFaces v1.1.5 > > > > Trinidad v1.0.3 > > > > Jetty 6.1.5 > > > > Firefox: 2.0.0.9 / IE 6.0 > > > > > > > > I've tried a few ways of doing this. > > > > 1. Attempt the generation and download in the dialogs return method. > > This > > > > causes an invalid PPR response (as seen using FireBug) > > > > > > > > public void handleDialogReturn(ReturnEvent evt) { > > > > FacesContext context = FacesContext.getCurrentInstance(); > > > > > > > > HttpServletResponse response = > > > > ( HttpServletResponse ) context.getExternalContext > > ().getResponse(); > > > > > > > > OutputStream out = null; > > > > InputStream in = null; > > > > try > > > > { > > > > in = getService().generateReport( > > > > selectedReport, getSelectedMonth(), > > getSelectedYear(), > > > > getReportType()); > > > > > > > > if (in != null) { > > > > > > > > response.setContentType(getReportContentType()); // > i.e. > > > > "application/vnd.ms-excel" > > > > response.setHeader ("Content-Disposition", > > > > "attachment;filename=\"" > > > > + selectedReport.getFilename() "); > > > > > > > > out = response.getOutputStream(); > > > > > > > > int read = -1; > > > > byte[] buffer = new byte[1024]; > > > > > > > > while ((read = in.read(buffer, 0, buffer.length)) > != > > -1) { > > > > out.write (buffer, 0, read); > > > > } > > > > > > > > out.flush(); > > > > } > > > > } > > > > catch (IOException ex) { > > > > > > > > } > > > > finally > > > > { > > > > try > > > > { > > > > out.close(); > > > > } > > > > catch (Exception ex) {} > > > > try > > > > { > > > > in.close(); > > > > } > > > > catch (Exception ex) {} > > > > } > > > > context.responseComplete(); > > > > } > > > > > > > > 2. Try to do the same thing in the actionListener method of the > dialog's > > > > commandButton. The download here works, however, when calling the > > > > returnFromDialog method, I get the following exception and the > > dialog > > > > remains in view: > > > > > > > > Caused by: java.lang.IllegalStateException : STREAM > > > > at org.mortbay.jetty.Response > > > > .getWriter(Response.java:583) > > > > at > > > > > > javax.servlet.ServletResponseWrapper.getWriter( > ServletResponseWrapper.java:122) > > > > at > > > > > > > org.apache.myfaces.trinidadinternal.renderkit.core.CoreRenderKit._getHtmlWriter > > (CoreRenderKit.java:744) > > > > at > > > > > > > org.apache.myfaces.trinidadinternal.renderkit.core.CoreRenderKit.returnFromDialog > > > > (CoreRenderKit.java:282) > > > > at > > > > > > > org.apache.myfaces.trinidadinternal.context.DialogServiceImpl.returnFromDialog > > (DialogServiceImpl.java:173) > > > > at > > > > > > > org.apache.myfaces.trinidadinternal.context.RequestContextImpl.returnFromDialog > > > > (RequestContextImpl.java:122) > > > > > > > > > > > > Any comments/suggestions would be highly appreciated, > > > > > > > > thanks, > > > > Oscar > > > > > > > > > > > > -- > > > Matthias Wessendorf > > > > > > further stuff: > > > blog: http://matthiaswessendorf.wordpress.com/ > > > mail: matzew-at-apache-dot-org > > > > > > > > > > > -- > Matthias Wessendorf > > further stuff: > blog: http://matthiaswessendorf.wordpress.com/ > mail: matzew-at-apache-dot-org >

