Coming Up for Air

JSF and File Downloads, Take Two

Wednesday, April 05, 2006 |

Yesterday, I detailed some issues I was having getting a JSF app to allow the download of an Excel spreadsheet as the result of a backing bean action being called. My solution involved a servlet and some JavaScript, with just a -pinch- a fistful of kludge.

Thanks to the esteemed Mr. Chad Cummings, I have a better solution, and it involves one small change to the backing bean (the navigation target returned) and the addition of this snippet to the JSF page:

<h:panelGrid columns="1" rendered="#{batchAuditReportBean.workBook != null}">
        <iframe src="success.jsp" style="visibility: hidden"/>

Is it still a bit of a hack? Maybe so, but it does work, and is a whole lot cleaner. That’s a plus in my book, so I’m going to commit this to our Subversion repository.



    Sample quote

    Quote source


    My name is Jason Lee. I am a software developer living in the middle of Oklahoma. I’ve been a professional developer since 1997, using a variety of languages, including Java, Javascript, PHP, Python, Delphi, and even a bit of C#. I currently work for Red Hat on the WildFly/EAP team, where, among other things, I maintain integrations for some MicroProfile specs, OpenTelemetry, Micrometer, Jakarta Faces, and Bean Validation. (Full resume here. LinkedIn profile)

    I am the president of the Oklahoma City JUG, and an occasional speaker at the JUG and a variety of technical conferences.

    On the personal side, I’m active in my church, and enjoy bass guitar, running, fishing, and a variety of martial arts. I’m also married to a beautiful woman, and have two boys, who, thankfully, look like their mother.

    My Links