Issue: Action method and setter for file not getting called on file upload.
I did see the link for JSF 2.2 not working, but it is over 4 years old and I thought the problem should have been resolved. I am posting this since I am facing it today!
I am using JSF 2.2.10, JBoss 6.4; I have mojarra set up in JBoss config as follows: (in \modules\system\layers\base\org\jboss\weld\core\main and \modules\system\layers\base\org\jboss\as\weld\main)
I have set up my xhtml and Controller as follows. Would greatly appreciate if you could point out what I am missing. Been stuck with this for more than a day now!
<h:form id="massUpload" enctype="multipart/form-data">
<div class="col-xs-3 col-md-3">
<h:inputFile id="file" value="#{controller.uploadedFile}" />
<h:commandButton value="Upload"
action="#{controller.massUploadBranchGLInfoViaFile}"/>
</div>
</h:form>
Controller As follows:
@Named("controller")
@ViewScoped
public class MyController
extends AccessController
implements Serializable
{
private Part uploadedFile;
public String massUploadBranchGLInfoViaFile() throws IOException {
InputStream stream = uploadedFile.getInputStream();
addSuccessInfoToFlash("update-gl-success");
return "Success";
}
public void setUploadedFile(Part file){
this.uploadedFile = file;
}
public Part getUploadedFile(){
return this.uploadedFile;
}
}
Thank you very much Karthik