Problems with ComboBox and Form in immediate=false, writeThrough=false

Hello.

I’ve a problem with a Form with a ComboBox.
I create the form this way:

editForm = new Form();
editForm.setWriteThrough(false);
editForm.setInvalidCommitted(false);
editForm.setImmediate(false);

then I add some Fields, among which there is a ComboBox, this way:

Field newField;
// Instantiate field object as required...
newField.setMultiSelect(false);
newField.setNullSelectionAllowed(true);
newField.setNewItemsAllowed(false);
((AbstractComponent) field).setImmediate(false);

I also set Validators and mark fields required, calling

newField.addValidator(myValidator);
newField.setRequired(true);
newField.setRequiredError(myMessageError);

The behaviour I’m experiencing is that, when I click on the ComboBox (in order to pull down the menu), it tries to validate all fields marked as required and that have some content! This is far from what I was expecting, that is: nothing until I press my commit button.
Of course, since the field is in immediate=false, it doesn’t update the value, so it gets always not validated (the message error I get is the requiredError.

Is this normal? From all the tests and tentatives I’ve done, it seems to me the ComboBox sends some sort of refresh/submit/post it should not.

Thanks in advance for any hint.

Regards,

Fabio Da Soghe

I’m verifying this behaviour with the Select component too: when I click on a value, other fields with required=true get validated immediately (they shoudn’t because they have immediate=false and writeThrough=false.

Hasn’t anyone any clue about this?

Sorry but… this bug is present in the Form demo on the official site, too!

In this page: http://demo.vaadin.com/sampler#FormBasic

That form is in buffering mode, as my example. To reproduce, follow these steps:

  • insert required datas (password has to have at least 6 chars)
  • press apply: all works fine (data is accepted)
  • delete some chars from the password field, leaving only 2 chars, but DON’T press apply. The field is not validated yet, as expected.
  • pull down the combo box (field Country).
  • BAM! the password field gets validated istantly, before pressing apply.

The validation in this case is right: the password is wrong. But the question is: why it gets validated when I pull down the combo box?

Any clue? This thing is making me going crazy… I wonder if forms are usable at all or I have to manage every field in a custom way?

I’ve done some deep digging.

What I’ve understood (it would be nice to know from someone expert if I’m right or not) is:

  1. Validation on every field is always active, and it gets called every time the value changes.
  2. Validation results are displayed as soon as the field (client side) is repainted.
  3. Turning off displaying validation calling AbstractField.setValidationVisible is useless in this scenario: it breaks all the validation chain up to the form object, which is not able to display the error message anymore.
  4. Pulling down the combo box does trigger a repaint of the whole form. This causes the unexpected (for me) validation (and since I’m in buffering mode not writeThrough, it never gets validated).

So, my original question: are forms usable in true buffered mode (that is: the input values get written in the data source bean only when committed) or not?

Hi,

I 've the same problem.
Did you find any solution?

Andreas

Making validation not visible and only turning it on when committing the form (or explicitly setting the form error message based on a call to validate() at that time) might help.

You should never rely on immediate=false not transmitting information - it is just an “optimization hint” to the client and there can be many situations where communication is needed anyway, transmitting all pending user actions and fetching all pending updates.