I am doing upload functionality from CAF Screen and getting conversion errors. Below are the details.
1.I have taken FileItem of type - com.webMethods.caf.faces.servlet.FileItemWrapper in my Bean variable and binded the same to my FileInput control in my screen.
once the file is selected and attempted to submit, am doing the below.
InputStreamReader in = new InputStreamReader(this.getUserFranchisemappingUploadVO().getFileItem().getInputStream());
3.But am getting the error “java.lang.IllegalArgumentException: Cannot convert UserFranchiseMappingUpload_Template.csv of type class com.webMethods.rtl.util.obj.PortalFileBean$PFBFileItem to class com.webMethods.caf.faces.servlet.FileItemWrapper”.
I would advise just using the org.apache.commons.fileupload.FileItem interface for the data type of your field instead of a specific implementation. That should work for any implementation of FileItem.
For example, below is what is generated in your page bean when you drag/drop the “Data > File > File Item” item from the Palette onto your view (or onto your managed bean in the Bindings view):
private org.apache.commons.fileupload.FileItem fileItem = null;
private static final String[][] FILEITEM_PROPERTY_BINDINGS = new String[][] {
};
public org.apache.commons.fileupload.FileItem getFileItem() {
if (fileItem == null) {
//TODO: create/set default value here
}
resolveDataBinding(FILEITEM_PROPERTY_BINDINGS, fileItem, "fileItem", false, false);
return fileItem;
}
public void setFileItem(org.apache.commons.fileupload.FileItem fileItem) {
this.fileItem = fileItem;
}