on smartgwt 2.4/ firefox 4.0.1
I am developing a handler that limits characters length in a textitem,
this handler implements ChangeHandler as the sample code below:
public class CharCountingHandler implements ChangeHandler {
private int max;
private String preValue = "";
private String targetItem;
public CharHandler(String targetItem, int max) {
this.targetItem = targetItem;
this.max = max;
}
public void onChange(ChangeEvent event) {
String value = event.getValue().toString();
if (value.length() > max) {
event.getItem().setValue(preValue);
} else {
preValue = value;
int rest = max - value.length();
((StaticTextItem) event.getForm().getItem(targetItem)).setValue(rest + " remains");
}
}
}
when i type (add) the characters in the textitem, everything is as i expect. But my question is, if characters in the textitem deleted to "empty",
the ChangeEvent doesn't emit as normal.
I am developing a handler that limits characters length in a textitem,
this handler implements ChangeHandler as the sample code below:
public class CharCountingHandler implements ChangeHandler {
private int max;
private String preValue = "";
private String targetItem;
public CharHandler(String targetItem, int max) {
this.targetItem = targetItem;
this.max = max;
}
public void onChange(ChangeEvent event) {
String value = event.getValue().toString();
if (value.length() > max) {
event.getItem().setValue(preValue);
} else {
preValue = value;
int rest = max - value.length();
((StaticTextItem) event.getForm().getItem(targetItem)).setValue(rest + " remains");
}
}
}
when i type (add) the characters in the textitem, everything is as i expect. But my question is, if characters in the textitem deleted to "empty",
the ChangeEvent doesn't emit as normal.
Comment