File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes File Download problem using icefaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "File Download problem using icefaces" Watch "File Download problem using icefaces" New topic

File Download problem using icefaces

Mary Cole
Ranch Hand

Joined: Dec 02, 2000
Posts: 362
I am using icefaces with liferay and am trying to download a file( it should open up the download dialogue box) from DB using the attached code. I have a command link on the webpage and currently if I click on that link, the method gets called, the inputstream is not null, but on the browser nothing happens.

Am I missing something? please help
pc pcqsajhd

Joined: Jul 24, 2012
Posts: 1
I think this might be a bit late but...

You need to tell icefaces to use the standard renderer on the page by doing the following

see the documentation here:
simone santos

Joined: May 20, 2013
Posts: 4
I am using icefaces 1.8 with liferay 5.2.3 and am trying to download a file, but the download no performs, no show error and no start download, no
Please can someone help me does nothing
x is list of data, I have on datatable that the user will select the file for download can be all ou one file

public void download() {

List<File> files = new ArrayList<File>();
for (Dados dado : x) {
if (dado.isMarcador()) {
File file = new File(dado.getCaminho());
if (file.exists()) {
if (!files.isEmpty()) {

private static final int DEFAULT_BUFFER_SIZE = 10240; // 10KB.

private void download1(List<File> files) {

PortletResponse portletResponse = (PortletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
HttpServletResponse response = PortalUtil.getHttpServletResponse(portletResponse);

response.setHeader("Content-Disposition", "attachment; filename=\"\"");
ZipOutputStream output = null;
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];

try {
output = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream(), DEFAULT_BUFFER_SIZE));

for (File file : files) {
InputStream input = new FileInputStream(file);
try {
input = new BufferedInputStream(input, DEFAULT_BUFFER_SIZE);
output.putNextEntry(new ZipEntry(file.getName()));
for (int length = 0; (length = > 0;) {
output.write(buffer, 0, length);
// System.out.println("wrote: "+length);
} catch (IOException e) {
} finally {
if (input != null) {
try {
} catch (IOException logOrIgnore) { /*
*/ }
} catch (FileNotFoundException e) {
} catch (IOException e) {
} finally {
if (output != null) {
try {
} catch (IOException logOrIgnore) { /*
*/ }

<!-- <h:commandButton value="Download Selected" action="#{}" rendered="#{selectt.displayFor}"/>

Please help me
thank you
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

Welcome to the JavaRanch, Simone!

A couple of hints. Rather than append to an old message thread (which we call "resurrecting a zombie"), it's better to start a thread of your own. Also, we have a "Code" button that can wrap special tags around code and XML samples, which helps make them more readable.

As a general rule, you should not use JSF to produce downloaded content. Use a traditional servlet for that purpose. JSF won't mind. It can even provide data for the servlet using shared session-scope beans.

JSF is designed to produce HTML forms and similar content. If you attempt to force it to produce non-HTML output, the code tends to be both ugly and unreliable. A servlet can do it much more simply and you're less likely to see things break when new versions of JSF come along.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: File Download problem using icefaces
jQuery in Action, 3rd edition