I am trying to use JSF 2.2 new to let the user upload a photografy to his profile. Anyway I need an Ajax behavior, which I achieved with the following snippet:
<h:form enctype="multipart/form-data">
<h:inputFile value="#{usuarioController.part}">
<f:ajax listener="#{usuarioController.uploadImage}"/>
</h:inputFile>
</h:form>
But at the moment my public void uploadImage()
the javax.servlet.http.Part
part still null..
This is the controller:
@Named(value="usuarioController")
@SessionScoped
public class UsuarioController extends GenericPersonificacaoCrudController<Usuario>{
private static final long serialVersionUID = 3233882970467365819L;
private Part part;
public void uploadImage(){
System.out.println(part);
}
public Part getPart() {
return part;
}
public void setPart(Part part) {
this.part = part;
}
}
I am using Mojarra 2.2.6 implementation of JSF with Tomcat + Weld CDI and Primefaces 5.1 which is unrelated to the question since I am using the native fileUpload component, but I am including just to let you know I also tried using it and it doesnt work with the mode="advanced"
which use ajax, what make me wonder if it is some kind of incompatibility or conflict of the libraries I am using.