I am using JSF 2.2 framework using primefaces, but I am unable to create multiple files import .I have tried using the lots of option but it doesn't work
public static Collection getAllParts(Part part) throws ServletException, IOException {
HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
return request.getParts().stream().filter(p -> part.getName().equals(p.getName())).collect(Collectors.toList());
}
public void submit() throws ServletException, IOException {
for (Part part : getAllParts(file)) {
String fileName = part.getSubmittedFileName();
InputStream fileContent = part.getInputStream();
// ...
//
// E.g. https://stackoverflow.com/q/14211843/157882
}
}
But it is still not working.Moreover HttpServletRequest request is returning null value. Please help me in resolving this issue
javax.servlet.*
API is not available. That's your #1 mistake. You need thejavax.portlet.*
ones instead, such asPortletRequest
. Have you already tried Googling around with keywords like "Multiple file upload using Liferay 7" instead of "Multiple file upload using JSF"? When I try so then I see relatively a lot of apparently useable examples. – BalusC