I'm trying to upload a file with a simple form but it just returns to the same page all the time. To find the mistake or whatever is wrong, I just want to write in the output the name of the file I upload. Once I can get the file name I guess I can handle how to handle the entire file. So this is my code:
<h:form enctype="multipart/form-data">
<h:outputText value="Argazkia: "/>
<p:fileUpload value="#{jokoBerriaController.file}" mode="simple"/>
<p:commandButton value="Bidali" ajax="false" actionListener="#{jokoBerriaController.upload()}"/>
</h:form>
The controller:
import javax.faces.bean.ManagedBean;
import org.primefaces.model.UploadedFile;
@ManagedBean
public class jokoBerriaController {
public static UploadedFile file;
public UploadedFile getFile() {
return file;
}
public void setFile(UploadedFile file) {
this.file = file;
}
public void upload() {
System.out.println("file " + file.getFileName());
}
}
I had added
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
at my web.xml file, but i've haven't added commons-io and commons-fileupload libraries. I've read that i have to put the next code in my pom.xml file, but I can't find that file.
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
</dependency>
Thanks for your help.
PD: Sorry about my English.