Yes this is possible, I could give better way to do this in Trinidad but here are the basics.
1. Open a new window having a URL that you predefine. Use either a third part component that does this or write your own javascript if usinig core JSF.
2. Write a servlet that processes the URL and returns the contents of the file requested. Set mime type of the page to application/xls and set response size to appropriate number of bytes. Servlet can be written in variety of ways.
Thanks, I'd like to clear some things...
1) In opening a new window, is it like in commandlink setting target="blank"?
2) I have my process for the excel in my bean. Here's a snippet of my code:
HttpServletResponse hResponse = ((HttpServletResponse) response);
OutputStream destination = hResponse.getOutputStream();
hResponse.setContentType("application/vnd.ms-excel");
//hResponse.addHeader("Content-Disposition","attachment; filename=\"Report_" +generatedDate + fileExtension+ "\"");
hResponse.addHeader("Content-Disposition","attachment; filename=\"Report"+fileExtension+"\"");
HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
How will I process the URL in the servlet/bean?
Here's my command button:
<h:commandButton value="#{messages['srt.export.label']}" action="#{myBean.excelExport}" immediate="true" />
Thank you! I hope you can help me here.
Message was edited by:
iamlei
I've been working on this and so far the only thing I've done is to have a pop up page... My problem is how to open the excel file in the pop up page...
Message was edited by:
iamlei
Hello, I have my pop up page by using this code:
<h:commandButton value="#{messages['srt.export.label']}" action="#{myBean.excelExport}" immediate="true" onclick="window.open(myBean.faces?=excelExport','','toolbars=yes')"/>
So I have accomplished having a pop up page once the user clicks on the export button (as shown in the above code). I also get a prompt to open, save, cancel the excel file.
The problem is when I choose to open the file, it still opens in the original page where the export button is, not on the pop up page that the export button has opened.
I'd like the excel file to open (to be embedded) in the pop up page that the export button has opened.
Hope my question is not confusing. Thanks a lot!