Textfield.setValue -> TextChangeEvent?

Hi everybody,

is there a way to “fire” a textchange event after setting the value of a textfield?
Example:

[code]
Textfield field = new Textfield();
field.setValue(“newValue”);

[/code]–> and now i need a textchangedevent :smiley:

thanks 4 help

field.addValueChangeListener(new ValueChangeListener(){
   public void valueChange(Property.ValueChangeEvent event){
		for (Object listener: field.getListeners(TextChangeEvent.class)) {
			listener.textChange(new TextChangeEventImpl(field));
		}
   }
});

hmm i´ve got problems with the “addValueChangeListener(…)”

→ cannot find symbol
symbol: method addValueChangeListener()
location: variable field of type TextField

there is not addValueChangeListener Method :frowning:

com.vaadin.ui.AbstractField.addValueChangeListener(com.vaadin.data.Property.ValueChangeListener)
TextField extends AbstractTextField extends AbstractField<String>

It’s addValueChangeListener(ValueChangeListener), not addValueChangeListener(TextChangeListener).

FWIW, I’d preferably extract the listener code into a dedicated method and call that method from both the ValueChangeListener and the TextChangeListener (if it is indeed the case that TextChangeListener is needed at all!) instead of manually firing TextChangeEvents from a ValueChangeListener. You should consider TextChangeEventImpl a non-public class.