PDA

View Full Version : length of GXT HtmlEditor



treblereel
27 Jan 2012, 12:31 AM
Hi All,

How i can set length (chars) of HtmlEditor? look like i missing somethings in the docs ...

swtor119
13 Feb 2012, 11:58 PM
Can you say a little more detail ?

dariusjb
5 Mar 2012, 2:29 AM
You can't, HtmlEditor extends Field, But MaxLength is only starting with TextField

So, you must write your own, and do like TextField, overriding the validateValue

new HtmlEditor(){
@Override
protected boolean validateValue(String value) {
boolean result = super.validateValue(value);
if (!result) {
return false;
}

//COPIED FROM TEXTFIELD
int length = value.length();

if (length > maxLength) {
String error = "";
if (getMessages().getMaxLengthText() == null) {
error = GXT.MESSAGES.textField_maxLengthText(maxLength);
} else {
error = Format.substitute(getMessages().getMaxLengthText(), maxLength);
}
markInvalid(error);
return false;
}
}
};

dariusjb
5 Mar 2012, 2:33 AM
I forgot to tell:

//MAKE YOUR OWN GETTER/SETTER for MaxLength
private int maxLength;