CAF- File format Conversion error

Dear Team,

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.

  1. 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”.

Pls help me in suggesting the prefered Type.

Regards,
SK.

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;
	}

Hello Eric, Thank you for the reply.

But how to select this entity? when i tried to add fileInput related entity to my bean variable, i am able to see the list attched below.

Please let me knoow, what type i need to select there
snapshot.jpg

I don’t really follow what you are attempting to do there. Please describe the symptoms of the problem carefully and clearly.