I am using myfaces ExtensionFilter to upload a file, but the file is not getting set to my bean for further processing.
Here is the code :
<h:form id="uploadFileForm" enctype="multipart/form-data">
<tom:inputFileUpload id="file"
value="#{paramUpload.uploadFile}">
<f:valueChangeListener type="com.bosch.de.plcd.plugin.ParamFileUpload" />
</tom:inputFileUpload>
<a4j:commandButton value="#{tpMsgs.upload}"
styleClass="button" action="#{paramUpload.uploadParamFile}"
onclick="javascript:updateParentScreen();">
</a4j:commandButton>
</h:form>
and web.xml configuration is as below
<filter>
<filter-name>Extensions Filter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Extensions Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
Since UploadFile
was not set to bean, I also tried using ValueChangeListener, never the less, its not se to bean :)
Bean code
public class ParamFileUpload implements ValueChangeListener {
private UploadedFile uploadFile;
public void uploadParamFile() {
if(uploadFile != null) {
LOGGER.info("File type: " + uploadFile.getContentType());
LOGGER.info("File name: " + uploadFile.getName());
LOGGER.info("File size: " + uploadFile.getSize() + " bytes");
}
}
public UploadedFile getUploadFile() {
return uploadFile;
}
public void setUploadFile(UploadedFile uploadFile) {
this.uploadFile = (UploadedFile)uploadFile;
}
public void processValueChange(ValueChangeEvent event)
throws AbortProcessingException {
this.uploadFile = (UploadedFile) event.getNewValue();
}
}
Do you see any other configuration that I might be missing here?