PDA

View Full Version : File upload and request values


vinaygajjar
Nov 20th, 2005, 12:59 AM
Hi,
I am trying to get file upload working on one of my projectcs. It seems to work. But I have got one problem.
I am using commons multipart resolver and have used ByteArrayMultipartFileEditor for binding input file as byte array. I am also having a few more fields that will pass on some values with the file. The fields on form are :

Name (String), Description(String), Price(Float) and File(file).

I am using simpleformcontroller here. So when i come to thie html form for the first time, formBackingObject is called. Now I want to submit this form. It does not post back and call my OnSubmit method , if I dont fill out all 4 values. Means if I provide values for Name,Description and File , and keep the price field empty
it doesn't submit, it stays on the page without doing anything.

I appreciate any help on this.

Thank you

vinaygajjar
Nov 20th, 2005, 01:09 AM
By default, empty values are not converted to null in spring I think. I just added following line in initBinder and it worked

binder.registerCustomEditor(Float.class,new CustomNumberEditor(Float.class,true));

the true value, indicates that empty values will be treated as nulls.