GWT/Sencha GXT Text area validation shows false negative

388 views Asked by At

Even though GWT text area contains text when the validate is method is called it fails.

 //Populating the data in a seperate method
 evntCommonWidget.getDescription().setText(obj.getDescription());

 //test to check whether data is getting populated
 int curPos=this.getDescription().getCurrentValue().length();
 GWT.log("text area text size "+curPos);
 this.getDescription().setAllowBlank(false);

//Validation process 
if (!description.validate()) {
    this.getDescription().focus();
    return false;
}

Log shows, 00:12:12.550 [INFO] text area text size 4.

What is going wrong ? Please help to resolve

1

There are 1 answers

0
Igor Klimer On BEST ANSWER

The source of the problem is mentioned in the javadocs for setText (emphasis mine):

Sets the underlying DOM field's value directly, bypassing validation. This method does not update the field's value. To set the value with validation see setValue.

You should use the setValue(value, true) method instead - true is needed to fire the ValueChangeEvent and trigger validation.