BUG: IntegerValidator crash

Hello,

Please refer to
http://demo.vaadin.com/sampler#FormBasic
. If
Shoesize
is set to be blank and then submit the form, an exception is thrown:
com.vaadin.data.Property$ConversionException: java.lang.reflect.InvocationTargetException
at com.vaadin.data.util.MethodProperty.setValue(MethodProperty.java:716)
at com.vaadin.ui.AbstractField.commit(AbstractField.java:242)
at com.vaadin.ui.Form.commit(Form.java:336)
at com.vaadin.demo.sampler.features.form.FormPojoExample$2.buttonClick(FormPojoExample.java:72)
at sun.reflect.GeneratedMethodAccessor341.invoke(Unknown Source)

Please let me know how to prompt a message for the case.

Thanks,
Watt

Hi!

I reopened a ticket http://dev.vaadin.com/ticket/2568 that deals the issue at some level.

The example is bit problematic, as it should actually have the shoeSize field required or to be of type Integer (and that way allow null value). So depending on your requirements:

  • make the field required in the field factory

or

  • change the type of field (in the pojo) to Integer
  • call textField.setNullRepresentation(“”) in the fieldfactory to automatically set value of the shoesize to null when the field is emptied.

I hope this helps.

cheers,
matti

[quote]

  • make the field required in the field factory

[/quote] The solution works, but doesn’t meet my requirement.

[quote]

  • change the type of field (in the pojo) to Integer
  • call textField.setNullRepresentation(“”) in the fieldfactory to automatically set value of the shoesize to null when the field is emptied.

[/quote] The exception is still thrown after following your instructions.

My puzzle is that I could catch the exception (see code below), but the exception is still displayed in UI. Could the exception stack be replaced by an error message?

				
            	boolean isError = false;
            	try {
            		form.setComponentError(null);
            		form.commit();
            	} catch (Exception e) {
            		isError = true;
            	} finally {
            		if (isError) return;
            	}

Ticket http://dev.vaadin.com/ticket/2568 was marked as fixed, but it still could be reproduced (http://demo.vaadin.com/sampler#FormAdvancedLayout).

Thanks for pointing this out - fixed for the next 6.4 maintenance release by copying the fix from the other form example.