public void encodeBegin(
FacesContext context,
UIComponent component)
throws IOException
{
final BinaryFile fileComponent = (BinaryFile)component;
if (fileComponent.isRendered())
{
final HttpServletResponse response = this.getResponse(context);
final OutputStream stream = response.getOutputStream();
// - reset the reponse to clear out any any headers (i.e. so
// the user doesn't get "unable to open..." when using IE.)
response.reset();
final String fileName = fileComponent.getFileName();
if (fileComponent.isPrompt() && fileName != null && fileName.trim().length() > 0)
{
response.addHeader(
"Content-disposition",
"attachment; filename=\"" + fileName + '"');
}
Object value = fileComponent.getValue();
final String contentType = fileComponent.getContentType();
// - for IE we need to set the content type, content length and buffer size and
// then the flush the response right away because it seems as if there is any lag time
// IE just displays a blank page. With mozilla based clients reports display correctly regardless.
if (contentType != null && contentType.length() > 0)
{