Wildfly 8, Jsf2.2, Primefaces 5.3
I want to make some file name transformation, before it reaches Primefaces <p:fileUpload>
listener. So that UploadedFile
in listener has converted file name. My first idea were to use WebFilter
but apparently it's not so good. The reason is given in this StackOverflow answer https://stackoverflow.com/a/7444514/2023524
Because we are using apache commons, I've made a hack for it. Overwrite DiskFileItemFactory, and return adjusted file name.
public class MyFactory extends DiskFileItemFactory{
public FileItem createItem(String fieldName, String contentType,
boolean isFormField, String fileName) {
fileName = convertFileName(fileName);
return super.createItem(fieldName, contentType, isFormField, fileName);
}
Also Primefaces FileUploadFilter is overwritten to instantiate the new factory.
Is it possible something like that for native Jsf2.2 upload ?
EDIT: The reason for this idea: from file name should be stripped off some bad unicode characters. So in listener method always remains the right characters. The place to save a file is determined dynamically based on a file and a problem. So I'm not sure how to make a composite component for this.