Krithika Vittal
Krithika Vittal

Reputation: 1477

GWT/Sencha GXT Text area validation shows false negative

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

Upvotes: 1

Views: 394

Answers (1)

Igor Klimer
Igor Klimer

Reputation: 15321

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.

Upvotes: 1

Related Questions