Validators Fail

I have a TextField for which i have assigned a IntegerValidator.

field.addValidator(new IntegerValidator("Enter a Valid Number"));

The validator works fine when the field is writable.

But when i make the field
readonly
, the validator throws the error irrespective of whether the field has numeric value or not…

This also happens with Doublevalidator and RegexpValidator(for numbers)

This happened both when the field was stand alone and also when it was a part of a form.

Am i doing something wrong??? Or is this a bug???

With the latest 6.4, at least IntegerValidator seems to validate things as it should also when entering the read-only mode - valid text is accepted and invalid rejected. I tested this with a standalone immediate text field, toggling the read-only flag with a checkbox.

If the problem persists, could you write a small example program with which you can reproduce this with Vaadin 6.4.6?

Initially I was using Vaadin 6.4.2. Now I downloaded 6.4.6 and tried and I get the same error.

Could you post the source code of the test application so that we can take a closer look at this?
I believe it is very short, but would help us reproduce (and hopefully resolve) the problem more quickly.

This is my test code.


public class TestVaadin extends Application {
        Window main = new Window("Main");	
	public TextField field;
	public void init() {
		  setMainWindow(main);
		  
		  field = new TextField("Number");
		  field.setImmediate(true);
		  field.addValidator(new IntegerValidator("Enter a Valid Number"));
		  Button button = new Button("Click");
		  
		  button.addListener(new Button.ClickListener() {
			
			public void buttonClick(ClickEvent event) {
				int i =10;
				field.setValue(new Integer(i));
				field.setReadOnly(true);
				
			}
		});
		  main.addComponent(field);
		  main.addComponent(button);
	}
}

Thank you for the example.

The real problem is not related to the field being read-only, but AbstractStringValidator does not convert non-string values to strings prior to validation. Created
ticket 5785
about this.

Thanx a lot Henri…