This code might be of help :
For View :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ace="http://www.icefaces.org/icefaces/components"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Add products via CSV</title>
</h:head>
<h:body class="ice-skin-sam">
<h:form id="addProductsForm" enctype="multipart/form-data">
<ace:fileEntry id="fileEntry" label="#{fileEntryCallbackBean.label}" fileEntryListener="#{fileEntryCallbackBean.executeListener}" absolutePath="C:\temp" styleClass="ib" />
<h:commandButton styleClass="ib" value="Submit file" />
<div class="messages-holder"><h:messages styleClass="messages" showDetail="true" /></div>
</h:form>
</h:body>
</html>
Backing bean :
package uk.co.myRetailSoftware.portal.fileUpload.bean;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.util.StringTokenizer;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import org.icefaces.ace.component.fileentry.FileEntry;
import org.icefaces.ace.component.fileentry.FileEntryEvent;
import org.icefaces.ace.component.fileentry.FileEntryResults;
import org.portletfaces.bridge.GenericFacesPortlet;
import org.portletfaces.logging.Logger;
import org.portletfaces.logging.LoggerFactory;
import com.myRetailSoftware.webservices.ServiceHandlerProxy;
@ManagedBean(name="fileEntryCallbackBean")
@ViewScoped
public class FileEntryCallbackBean extends GenericFacesPortlet implements Serializable {
private static final long serialVersionUID = 1L;
private static final Logger logger = LoggerFactory
.getLogger(FileEntryCallbackBean.class);
public void executeListener(FileEntryEvent event)
{
FileEntry fileEntry = (FileEntry)event.getSource();
FileEntryResults entryResults = fileEntry.getResults();
File file = entryResults.getFiles().get(0).getFile();
try {
FileInputStream fileInputStream = new FileInputStream(file);
DataInputStream dataInputStream = new DataInputStream(fileInputStream);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(dataInputStream));
String strLine;
while((strLine = bufferedReader.readLine()) != null){
StringTokenizer stringTokenizer = new StringTokenizer(strLine, ",");
while(stringTokenizer.hasMoreTokens()){
logger.info(stringTokenizer.nextToken());
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}
This works for me .

Sameer
Please sign in to flag this as inappropriate.